pub(super) struct State {
val: AtomicUsize,
}
Fields§
§val: AtomicUsize
Implementations§
source§impl State
impl State
All transitions are performed via RMW operations. This establishes an unambiguous modification order.
sourcepub(super) fn transition_to_running(&self) -> TransitionToRunning
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.
sourcepub(super) fn transition_to_idle(&self) -> TransitionToIdle
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.
sourcepub(super) fn transition_to_complete(&self) -> Snapshot
pub(super) fn transition_to_complete(&self) -> Snapshot
Transitions the task from Running
-> Complete
.
sourcepub(super) fn transition_to_terminal(&self, count: usize) -> bool
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.
sourcepub(super) fn transition_to_notified_by_val(&self) -> TransitionToNotifiedByVal
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.
sourcepub(super) fn transition_to_notified_by_ref(&self) -> TransitionToNotifiedByRef
pub(super) fn transition_to_notified_by_ref(&self) -> TransitionToNotifiedByRef
Transitions the state to NOTIFIED
.
sourcepub(super) fn transition_to_notified_and_cancel(&self) -> bool
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.
sourcepub(super) fn transition_to_shutdown(&self) -> bool
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.
sourcepub(super) fn drop_join_handle_fast(&self) -> Result<(), ()>
pub(super) fn drop_join_handle_fast(&self) -> Result<(), ()>
Optimistically tries to swap the state assuming the join handle is immediately dropped on spawn.
sourcepub(super) fn unset_join_interested(&self) -> Result<Snapshot, Snapshot>
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.
sourcepub(super) fn set_join_waker(&self) -> Result<Snapshot, Snapshot>
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.
sourcepub(super) fn unset_waker(&self) -> Result<Snapshot, Snapshot>
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.
pub(super) fn ref_inc(&self)
sourcepub(super) fn ref_dec_twice(&self) -> bool
pub(super) fn ref_dec_twice(&self) -> bool
Returns true
if the task should be released.