pub(crate) struct TimerShared {
pointers: Pointers<TimerShared>,
registered_when: AtomicU64,
state: StateCell,
_p: PhantomPinned,
}
Expand description
The shared state structure of a timer. This structure is shared between the
frontend (Entry
) and driver backend.
Note that this structure is located inside the TimerEntry
structure.
Fields§
§pointers: Pointers<TimerShared>
A link within the doubly-linked list of timers on a particular level and slot. Valid only if state is equal to Registered.
Only accessed under the entry lock.
registered_when: AtomicU64
The time when the TimerEntry
was registered into the Wheel,
STATE_DEREGISTERED
means it is not registered.
Generally owned by the driver, but is accessed by the entry when not registered.
We use relaxed ordering for both loading and storing since this value
is only accessed either when holding the driver lock or through mutable
references to TimerEntry
.
state: StateCell
Current state. This records whether the timer entry is currently under the ownership of the driver, and if not, its current state (not complete, fired, error, etc).
_p: PhantomPinned
Implementations§
unsafe fn addr_of_pointers(me: NonNull<Self>) -> NonNull<Pointers<TimerShared>>
pub(super) fn new() -> Self
Sourcepub(super) fn registered_when(&self) -> u64
pub(super) fn registered_when(&self) -> u64
Gets the cached time-of-expiration value.
Sourcepub(super) unsafe fn sync_when(&self) -> u64
pub(super) unsafe fn sync_when(&self) -> u64
Gets the true time-of-expiration value, and copies it into the cached time-of-expiration value.
SAFETY: Must be called with the driver lock held, and when this entry is not in any timer wheel lists.
Sourceunsafe fn set_registered_when(&self, when: u64)
unsafe fn set_registered_when(&self, when: u64)
Sets the cached time-of-expiration value.
SAFETY: Must be called with the driver lock held, and when this entry is not in any timer wheel lists.
Sourcepub(super) fn true_when(&self) -> u64
pub(super) fn true_when(&self) -> u64
Returns the true time-of-expiration value, with relaxed memory ordering.
Sourcepub(super) unsafe fn set_expiration(&self, t: u64)
pub(super) unsafe fn set_expiration(&self, t: u64)
Sets the true time-of-expiration value, even if it is less than the current expiration or the timer is deregistered.
SAFETY: Must only be called with the driver lock held and the entry not in the timer wheel.
Sourcepub(super) fn extend_expiration(&self, t: u64) -> Result<(), ()>
pub(super) fn extend_expiration(&self, t: u64) -> Result<(), ()>
Sets the true time-of-expiration only if it is after the current.
Sourcepub(super) fn handle(&self) -> TimerHandle
pub(super) fn handle(&self) -> TimerHandle
Returns a TimerHandle
for this timer.
Sourcepub(super) fn might_be_registered(&self) -> bool
pub(super) fn might_be_registered(&self) -> bool
Returns true if the state of this timer indicates that the timer might be registered with the driver. This check is performed with relaxed ordering, but is conservative - if it returns false, the timer is definitely not registered.