pub(crate) struct TimerEntry {
driver: Handle,
inner: UnsafeCell<Option<TimerShared>>,
deadline: Instant,
registered: bool,
_m: PhantomPinned,
}
Expand description
A timer entry.
This is the handle to a timer that is controlled by the requester of the timer. As this participates in intrusive data structures, it must be pinned before polling.
Fields§
§driver: Handle
Arc reference to the runtime handle. We can only free the driver after deregistering everything from their respective timer wheels.
inner: UnsafeCell<Option<TimerShared>>
Shared inner structure; this is part of an intrusive linked list, and therefore other references can exist to it while mutable references to Entry exist.
This is manipulated only under the inner mutex. TODO: Can we use loom cells for this?
deadline: Instant
Deadline for the timer. This is used to register on the first poll, as we can’t register prior to being pinned.
registered: bool
Whether the deadline has been registered.
_m: PhantomPinned
Ensure the type is !Unpin
Implementations§
source§impl TimerEntry
impl TimerEntry
pub(crate) fn new(handle: Handle, deadline: Instant) -> Self
fn is_inner_init(&self) -> bool
fn inner(&self) -> &TimerShared
pub(crate) fn deadline(&self) -> Instant
pub(crate) fn is_elapsed(&self) -> bool
sourcepub(crate) fn cancel(self: Pin<&mut Self>)
pub(crate) fn cancel(self: Pin<&mut Self>)
Cancels and deregisters the timer. This operation is irreversible.