mirror of
https://github.com/scottlamb/moonfire-nvr.git
synced 2025-01-11 15:03:23 -05:00
include suspended time in monotonic timestamps
This commit is contained in:
parent
156d3dde9d
commit
901ba121a2
@ -18,7 +18,10 @@ pub trait Clocks: Send + Sync + 'static {
|
||||
/// Gets the current time from `CLOCK_REALTIME`.
|
||||
fn realtime(&self) -> Timespec;
|
||||
|
||||
/// Gets the current time from `CLOCK_MONOTONIC`.
|
||||
/// Gets the current time from a monotonic clock.
|
||||
///
|
||||
/// On Linux, this uses `CLOCK_BOOTTIME`, which includes suspended time.
|
||||
/// On other systems, it uses `CLOCK_MONOTONIC`.
|
||||
fn monotonic(&self) -> Timespec;
|
||||
|
||||
/// Causes the current thread to sleep for the specified time.
|
||||
@ -70,6 +73,13 @@ impl Clocks for RealClocks {
|
||||
fn realtime(&self) -> Timespec {
|
||||
self.get(libc::CLOCK_REALTIME)
|
||||
}
|
||||
|
||||
#[cfg(target_os = "linux")]
|
||||
fn monotonic(&self) -> Timespec {
|
||||
self.get(libc::CLOCK_BOOTTIME)
|
||||
}
|
||||
|
||||
#[cfg(not(target_os = "linux"))]
|
||||
fn monotonic(&self) -> Timespec {
|
||||
self.get(libc::CLOCK_MONOTONIC)
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user