pub struct Task { /* private fields */ }Expand description
A task reference that runs its future.
At any moment in time, there is at most one Task reference associated
with a particular task. Running consumes the Task reference and polls
its internal future. If the future is still pending after getting polled,
the Task reference simply won’t exist until a Waker notifies the
task. If the future completes, its result becomes available to the
JoinHandle.
When a task is woken up, its Task reference is recreated and passed to
the schedule function. In most executors, scheduling simply pushes the
Task reference into a queue of runnable tasks.
If the Task reference is dropped without getting run, the task is
automatically canceled. When canceled, the task won’t be scheduled again
even if a Waker wakes it. It is possible for the JoinHandle to
cancel while the Task reference exists, in which case an attempt
to run the task won’t do anything.