Commit 4417b8bf authored by Thomas Haller's avatar Thomas Haller

core: add nm_utils_get_monotonic_timestamp_ns_cached() helper

Add a helper function to cache the current timestamp and return
it. The caching is a performance optimization, but it serves a
much more important purpose: repeatedly getting the timestamp
likely will yield different timings. So, commonly, within a
certain context we want to get the current time once, and stick
to that as "now".
parent 43dee5f1
......@@ -239,6 +239,13 @@ gint64 nm_utils_get_monotonic_timestamp_ms (void);
gint32 nm_utils_get_monotonic_timestamp_s (void);
gint64 nm_utils_monotonic_timestamp_as_boottime (gint64 timestamp, gint64 timestamp_ticks_per_ns);
static inline gint64
nm_utils_get_monotonic_timestamp_ns_cached (gint64 *cache_now)
return (*cache_now)
?: (*cache_now = nm_utils_get_monotonic_timestamp_ns ());
gboolean nm_utils_is_valid_path_component (const char *name);
const char *NM_ASSERT_VALID_PATH_COMPONENT (const char *name);
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment