summaryrefslogtreecommitdiff
path: root/monoio/src/time/clock.rs
blob: 410d2d45856a18c8cba177d097105388c1b4354c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
//! Source of time abstraction.
//!
//! By default, `std::time::Instant::now()` is used. However, when the
//! `test-util` feature flag is enabled, the values returned for `now()` are
//! configurable.

use crate::time::Instant;

#[derive(Default, Debug, Clone)]
pub(crate) struct Clock {}

pub(crate) fn now() -> Instant {
    Instant::from_std(std::time::Instant::now())
}

impl Clock {
    pub(crate) fn new() -> Clock {
        Clock {}
    }

    pub(crate) fn now(&self) -> Instant {
        now()
    }
}