pub(crate) struct TimerShared {
shard_id: u32,
pointers: Pointers<TimerShared>,
cached_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§
§shard_id: u32
The shard id. We should never change it.
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.
cached_when: AtomicU64
The expiration time for which this entry is currently registered. Generally owned by the driver, but is accessed by the entry when not registered.
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(shard_id: u32) -> Self
sourcepub(super) fn cached_when(&self) -> u64
pub(super) fn cached_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_cached_when(&self, when: u64)
unsafe fn set_cached_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.