Struct tokio::runtime::time::entry::TimerShared

source ·
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§

source§

impl TimerShared

source§

impl TimerShared

source

pub(super) fn new(shard_id: u32) -> Self

source

pub(super) fn cached_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_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.

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.

source

pub(super) fn shard_id(&self) -> u32

Gets the shard id.

Trait Implementations§

source§

impl Debug for TimerShared

source§

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

Formats the value using the given formatter. Read more
§

type Handle = TimerHandle

Handle to the list entry. Read more
§

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>,

§

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>,

§

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.