Skip to content

Commit

Permalink
re-export time utils
Browse files Browse the repository at this point in the history
  • Loading branch information
fafhrd91 committed Nov 26, 2019
1 parent 4ceac79 commit 5efac44
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 0 deletions.
2 changes: 2 additions & 0 deletions actix-rt/CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
20 changes: 20 additions & 0 deletions actix-rt/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
}

0 comments on commit 5efac44

Please sign in to comment.