pub fn get_coarse_unix_timestamp() -> u64
Expand description
Get the current coarse Unix timestamp, in seconds.
In scenarios where the current Unix timestamp is needed frequently, this function provides a cached value that is updated periodically. As the precision of the timestamp is one second, this function allows trading off accuracy (see below) for reduced overhead. The resulting value is considered “coarse”, because it might be off by significant percentage of the overall precision.
§Accuracy
The underlying coarse time is updated roughly every 250 milliseconds, so the value returned by this function may be
behind by up to 250 milliseconds. This means that if calling the function at true time t
(where t
is in
seconds), the value returned may be t-1
or t
, but will never be behind by more than 250 milliseconds, and
never ahead of t
.