struct Task {
desc: String,
state: TaskState,
fut: Option<TaskFutureInfo>,
}
Expand description
Record of a single task
Tracks a spawned task, or the main task (the argument to block_on
).
Stored in Data
.tasks
.
Fields§
§desc: String
For debugging output
state: TaskState
Has this been woken via a waker? (And is it in Data.awake
?)
Set to Awake
only by Task::set_awake
,
preserving the invariant that
every Awake
task is in Data.awake
.
fut: Option<TaskFutureInfo>
The actual future (or a placeholder for it)
May be None
briefly in the executor main loop, because we’ve
temporarily moved it out so we can poll it,
or if this is a Subthread task which is currently running sync code
(in which case we’re blocked in the executor waiting to be
woken up by thread_context_switch
.
Note that the None
can be observed outside the main loop, because
the main loop unlocks while it polls, so other (non-main-loop) code
might see it.
Implementations§
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Task
impl !RefUnwindSafe for Task
impl Send for Task
impl !Sync for Task
impl Unpin for Task
impl !UnwindSafe for Task
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
Converts
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
Converts
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read more