mirror of
https://github.com/tokio-rs/tokio.git
synced 2026-08-24 00:00:11 +02:00
Moves when to Timeout from TimeoutToken
This commit is contained in:
@@ -8,7 +8,6 @@ use reactor::{Message, Handle, Remote};
|
||||
/// A token that identifies an active timeout.
|
||||
pub struct TimeoutToken {
|
||||
token: usize,
|
||||
when: Instant,
|
||||
}
|
||||
|
||||
impl TimeoutToken {
|
||||
@@ -17,23 +16,13 @@ impl TimeoutToken {
|
||||
pub fn new(at: Instant, handle: &Handle) -> io::Result<TimeoutToken> {
|
||||
match handle.inner.upgrade() {
|
||||
Some(inner) => {
|
||||
let (token, when) = try!(inner.borrow_mut().add_timeout(at));
|
||||
Ok(TimeoutToken { token: token, when: when })
|
||||
let token = inner.borrow_mut().add_timeout(at);
|
||||
Ok(TimeoutToken { token: token })
|
||||
}
|
||||
None => Err(io::Error::new(io::ErrorKind::Other, "event loop gone")),
|
||||
}
|
||||
}
|
||||
|
||||
/// Returns the instant in time when this timeout token will "fire".
|
||||
///
|
||||
/// Note that this instant may *not* be the instant that was passed in when
|
||||
/// the timeout was created. The event loop does not support high resolution
|
||||
/// timers, so the exact resolution of when a timeout may fire may be
|
||||
/// slightly fudged.
|
||||
pub fn when(&self) -> &Instant {
|
||||
&self.when
|
||||
}
|
||||
|
||||
/// Updates a previously added timeout to notify a new task instead.
|
||||
///
|
||||
/// # Panics
|
||||
|
||||
Reference in New Issue
Block a user