mirror of
https://github.com/tokio-rs/tokio.git
synced 2026-08-29 00:00:11 +02:00
Implement Default for tokio_timer::Handle (#553)
This patch implements `Default` for `tokio_timer::Handle`. It returns a `Handle` instance that is not bound to a specific timer. Instead, it will use the timer for the current execution context. This is the same strategy used by `tokio_reactor::Handle`. Fixes #547
This commit is contained in:
@@ -7,6 +7,7 @@ mod support;
|
||||
use support::*;
|
||||
|
||||
use tokio_timer::*;
|
||||
use tokio_timer::timer::Handle;
|
||||
|
||||
use futures::Future;
|
||||
|
||||
@@ -486,3 +487,19 @@ fn reset_future_delay_after_fire() {
|
||||
assert_ready!(delay);
|
||||
});
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn delay_with_default_handle() {
|
||||
let handle = Handle::default();
|
||||
let now = Instant::now();
|
||||
|
||||
let mut delay = handle.delay(now + ms(1));
|
||||
|
||||
mocked_with_now(now, |timer, _time| {
|
||||
assert_not_ready!(delay);
|
||||
|
||||
turn(timer, ms(1));
|
||||
|
||||
assert_ready!(delay);
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user