Struct tokio::runtime::task::state::State

source ·
pub(super) struct State {
    val: AtomicUsize,
}

Fields§

§val: AtomicUsize

Implementations§

source§

impl State

All transitions are performed via RMW operations. This establishes an unambiguous modification order.

source

pub(super) fn new() -> State

Returns a task’s initial state.

source

pub(super) fn load(&self) -> Snapshot

Loads the current state, establishes Acquire ordering.

source

pub(super) fn transition_to_running(&self) -> TransitionToRunning

Attempts to transition the lifecycle to Running. This sets the notified bit to false so notifications during the poll can be detected.

source

pub(super) fn transition_to_idle(&self) -> TransitionToIdle

Transitions the task from Running -> Idle.

The transition to Idle fails if the task has been flagged to be cancelled.

source

pub(super) fn transition_to_complete(&self) -> Snapshot

Transitions the task from Running -> Complete.

source

pub(super) fn transition_to_terminal(&self, count: usize) -> bool

Transitions from Complete -> Terminal, decrementing the reference count the specified number of times.

Returns true if the task should be deallocated.

source

pub(super) fn transition_to_notified_by_val(&self) -> TransitionToNotifiedByVal

Transitions the state to NOTIFIED.

If no task needs to be submitted, a ref-count is consumed.

If a task needs to be submitted, the ref-count is incremented for the new Notified.

source

pub(super) fn transition_to_notified_by_ref(&self) -> TransitionToNotifiedByRef

Transitions the state to NOTIFIED.

source

pub(super) fn transition_to_notified_and_cancel(&self) -> bool

Sets the cancelled bit and transitions the state to NOTIFIED if idle.

Returns true if the task needs to be submitted to the pool for execution.

source

pub(super) fn transition_to_shutdown(&self) -> bool

Sets the CANCELLED bit and attempts to transition to Running.

Returns true if the transition to Running succeeded.

source

pub(super) fn drop_join_handle_fast(&self) -> Result<(), ()>

Optimistically tries to swap the state assuming the join handle is immediately dropped on spawn.

source

pub(super) fn unset_join_interested(&self) -> Result<Snapshot, Snapshot>

Tries to unset the JOIN_INTEREST flag.

Returns Ok if the operation happens before the task transitions to a completed state, Err otherwise.

source

pub(super) fn set_join_waker(&self) -> Result<Snapshot, Snapshot>

Sets the JOIN_WAKER bit.

Returns Ok if the bit is set, Err otherwise. This operation fails if the task has completed.

source

pub(super) fn unset_waker(&self) -> Result<Snapshot, Snapshot>

Unsets the JOIN_WAKER bit.

Returns Ok has been unset, Err otherwise. This operation fails if the task has completed.

source

pub(super) fn ref_inc(&self)

source

pub(super) fn ref_dec(&self) -> bool

Returns true if the task should be released.

source

pub(super) fn ref_dec_twice(&self) -> bool

Returns true if the task should be released.

source

fn fetch_update_action<F, T>(&self, f: F) -> T
where F: FnMut(Snapshot) -> (T, Option<Snapshot>),

source

fn fetch_update<F>(&self, f: F) -> Result<Snapshot, Snapshot>
where F: FnMut(Snapshot) -> Option<Snapshot>,

Trait Implementations§

source§

impl Debug for State

source§

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

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl !Freeze for State

§

impl RefUnwindSafe for State

§

impl Send for State

§

impl Sync for State

§

impl Unpin for State

§

impl UnwindSafe for State

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.