mirror of
https://github.com/fafhrd91/actix-net
synced 2024-11-27 21:22:57 +01:00
re-export time utils
This commit is contained in:
parent
4ceac79f2c
commit
5efac449b1
@ -6,6 +6,8 @@ Added
|
|||||||
|
|
||||||
* Export `main` and `test` attribute macros
|
* Export `main` and `test` attribute macros
|
||||||
|
|
||||||
|
* Export `timer` module (re-export of tokio-timer)
|
||||||
|
|
||||||
|
|
||||||
## [1.0.0-alpha.1] - 2019-11-22
|
## [1.0.0-alpha.1] - 2019-11-22
|
||||||
|
|
||||||
|
@ -30,3 +30,23 @@ where
|
|||||||
|
|
||||||
Arbiter::spawn(f);
|
Arbiter::spawn(f);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Utilities for tracking time.
|
||||||
|
pub mod time {
|
||||||
|
use std::time::{Duration, Instant};
|
||||||
|
|
||||||
|
pub use tokio_timer::Interval;
|
||||||
|
pub use tokio_timer::{delay, delay_for, Delay};
|
||||||
|
|
||||||
|
/// Creates new `Interval` that yields with interval of `duration`. The first
|
||||||
|
/// tick completes immediately.
|
||||||
|
pub fn interval(duration: Duration) -> Interval {
|
||||||
|
Interval::new(Instant::now(), duration)
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Creates new `Interval` that yields with interval of `period` with the
|
||||||
|
/// first tick completing at `at`.
|
||||||
|
pub fn interval_at(start: Instant, duration: Duration) -> Interval {
|
||||||
|
Interval::new(start, duration)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user