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.
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 transition_to_join_handle_dropped(
&self,
) -> TransitionToJoinHandleDrop
pub(super) fn transition_to_join_handle_dropped( &self, ) -> TransitionToJoinHandleDrop
Unsets the JOIN_INTEREST
flag. If COMPLETE
is not set, the JOIN_WAKER
flag is also unset.
The returned TransitionToJoinHandleDrop
indicates whether the JoinHandle
should drop
the output of the future or the join waker after the transition.
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.
Sourcepub(super) fn unset_waker_after_complete(&self) -> Snapshot
pub(super) fn unset_waker_after_complete(&self) -> Snapshot
Unsets the JOIN_WAKER
bit unconditionally after task completion.
This operation requires the task to be 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.