mirror of
https://gitlab.freedesktop.org/NetworkManager/NetworkManager.git
synced 2025-12-26 00:40:08 +01:00
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".
This commit is contained in:
parent
43dee5f192
commit
4417b8bf3e
1 changed files with 7 additions and 0 deletions
|
|
@ -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);
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue