1
0
mirror of https://github.com/fafhrd91/actix-net synced 2024-11-23 22:51:07 +01:00

re-export time utils

This commit is contained in:
Nikolay Kim 2019-11-26 08:12:16 +06:00
parent 4ceac79f2c
commit 5efac449b1
2 changed files with 22 additions and 0 deletions

View File

@ -6,6 +6,8 @@ Added
* Export `main` and `test` attribute macros
* Export `timer` module (re-export of tokio-timer)
## [1.0.0-alpha.1] - 2019-11-22

View File

@ -30,3 +30,23 @@ where
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)
}
}