Struct TimerShared

Source
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§

Source§

impl TimerShared

Source§

impl TimerShared

Source

pub(super) fn new() -> Self

Source

pub(super) fn registered_when(&self) -> u64

Gets the cached time-of-expiration value.

Source

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.

Source

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.

Source

pub(super) fn true_when(&self) -> u64

Returns the true time-of-expiration value, with relaxed memory ordering.

Source

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.

Source

pub(super) fn extend_expiration(&self, t: u64) -> Result<(), ()>

Sets the true time-of-expiration only if it is after the current.

Source

pub(super) fn handle(&self) -> TimerHandle

Returns a TimerHandle for this timer.

Source

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.

Trait Implementations§

Source§

impl Debug for TimerShared

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

type Handle = TimerHandle

Handle to the list entry. Read more
Source§

type Target = TimerShared

Node type.
Source§

fn as_raw(handle: &Self::Handle) -> NonNull<Self::Target>

Convert the handle to a raw pointer without consuming the handle.
Source§

unsafe fn from_raw(ptr: NonNull<Self::Target>) -> Self::Handle

Convert the raw pointer to a handle
Source§

unsafe fn pointers( target: NonNull<Self::Target>, ) -> NonNull<Pointers<Self::Target>>

Return the pointers for a node Read more
Source§

impl Send for TimerShared

Source§

impl Sync for TimerShared

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.