pub struct TimerHandle(/* private fields */);Expand description
Handle to a timer registered with ntex’s local timer wheel.
Dropping the handle cancels the timer. A handle may be reset and reused after it has elapsed.
Timer operations are not reentrant. Registered wakers must not synchronously access the timer wheel when cloned, woken or dropped.
The handle refers to a slot in the current thread’s wheel, so it is neither
Send nor Sync, and neither are the timer futures that hold it. To run a
timer on another thread, send a future that creates it there instead of
one that already holds it.
Inside a native Runtime the timer is registered
with the wheel of that runtime. Once the runtime is dropped, or while it
is not active on the thread, the handle is stale: it reports the timer as
elapsed and ignores other operations.
Implementations§
Source§impl TimerHandle
impl TimerHandle
Sourcepub fn is_elapsed(&self) -> bool
pub fn is_elapsed(&self) -> bool
Returns true if this timer has elapsed.
Sourcepub fn poll_elapsed(&self, cx: &mut Context<'_>) -> Poll<()>
pub fn poll_elapsed(&self, cx: &mut Context<'_>) -> Poll<()>
Polls until this timer has elapsed.
The timer stores one waker: a pending poll replaces the previously registered one, so only the most recent waiter is woken.