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:
Carl Lerche
2018-08-20 13:01:39 -07:00
committed by GitHub
parent 89639ec48b
commit c66b56c3fb
5 changed files with 97 additions and 14 deletions
+3 -3
View File
@@ -1,6 +1,6 @@
use Error;
use atomic::AtomicU64;
use timer::{Handle, Inner};
use timer::{HandlePriv, Inner};
use futures::Poll;
use futures::task::AtomicTask;
@@ -121,7 +121,7 @@ const SHUTDOWN: *mut Entry = 1 as *mut _;
// ===== impl Entry =====
impl Entry {
pub fn new(when: u64, handle: Handle) -> Entry {
pub fn new(when: u64, handle: HandlePriv) -> Entry {
assert!(when > 0 && when < u64::MAX);
Entry {
@@ -137,7 +137,7 @@ impl Entry {
}
}
pub fn new_elapsed(handle: Handle) -> Entry {
pub fn new_elapsed(handle: HandlePriv) -> Entry {
Entry {
inner: handle.into_inner(),
task: AtomicTask::new(),