pub(crate) struct TimerHandle {
inner: NonNull<TimerShared>,
}
Expand description
An TimerHandle
is the (non-enforced) “unique” pointer from the driver to the
timer entry. Generally, at most one TimerHandle
exists for a timer at a time
(enforced by the timer state machine).
SAFETY: An TimerHandle
is essentially a raw pointer, and the usual caveats
of pointer safety apply. In particular, TimerHandle
does not itself enforce
that the timer does still exist; however, normally an TimerHandle
is created
immediately before registering the timer, and is consumed when firing the
timer, to help minimize mistakes. Still, because TimerHandle
cannot enforce
memory safety, all operations are unsafe.
Fields§
§inner: NonNull<TimerShared>
Implementations§
source§impl TimerHandle
impl TimerHandle
pub(super) unsafe fn cached_when(&self) -> u64
pub(super) unsafe fn sync_when(&self) -> u64
pub(super) unsafe fn is_pending(&self) -> bool
sourcepub(super) unsafe fn set_expiration(&self, tick: u64)
pub(super) unsafe fn set_expiration(&self, tick: u64)
Forcibly sets the true and cached expiration times to the given tick.
SAFETY: The caller must ensure that the handle remains valid, the driver lock is held, and that the timer is not in any wheel linked lists.
sourcepub(super) unsafe fn mark_pending(&self, not_after: u64) -> Result<(), u64>
pub(super) unsafe fn mark_pending(&self, not_after: u64) -> Result<(), u64>
Attempts to mark this entry as pending. If the expiration time is after
not_after
, however, returns an Err with the current expiration time.
If an Err
is returned, the cached_when
value will be updated to this
new expiration time.
SAFETY: The caller must ensure that the handle remains valid, the driver lock is held, and that the timer is not in any wheel linked lists. After returning Ok, the entry must be added to the pending list.
sourcepub(super) unsafe fn fire(
self,
completed_state: Result<(), Error>,
) -> Option<Waker>
pub(super) unsafe fn fire( self, completed_state: Result<(), Error>, ) -> Option<Waker>
Attempts to transition to a terminal state. If the state is already a terminal state, does nothing.
Because the entry might be dropped after the state is moved to a terminal state, this function consumes the handle to ensure we don’t access the entry afterwards.
Returns the last-registered waker, if any.
SAFETY: The driver lock must be held while invoking this function, and the entry must not be in any wheel linked lists.