pub struct StoredTask { /* private fields */ }Expand description
A type-erased future stored in the runtime.
This type holds a boxed future that has been wrapped to send its result through a oneshot channel. The actual output type is erased to allow storing heterogeneous futures in a single collection.
Implementations§
Source§impl StoredTask
impl StoredTask
Sourcepub fn new<F>(future: F) -> Self
pub fn new<F>(future: F) -> Self
Creates a new stored task from a future.
The future should already be wrapped to handle its result (typically by sending through a oneshot channel).
Sourcepub fn new_with_id<F>(future: F, task_id: TaskId) -> Self
pub fn new_with_id<F>(future: F, task_id: TaskId) -> Self
Creates a new stored task from a future with a task ID.
The task ID is used for tracing poll events.
Sourcepub fn set_task_id(&mut self, task_id: TaskId)
pub fn set_task_id(&mut self, task_id: TaskId)
Sets the task ID for tracing.
Sourcepub fn set_polls_remaining(&mut self, remaining: u32)
pub fn set_polls_remaining(&mut self, remaining: u32)
Sets the budget polls remaining for the next poll trace.
The executor should call this before each poll() to include
budget information in the trace output.
Sourcepub fn poll(&mut self, cx: &mut Context<'_>) -> Poll<Outcome<(), ()>>
pub fn poll(&mut self, cx: &mut Context<'_>) -> Poll<Outcome<(), ()>>
Polls the stored task.
Returns Poll::Ready(Outcome) when the task is complete, or Poll::Pending
if it needs to be polled again.
Sourcepub fn poll_count(&self) -> u64
pub fn poll_count(&self) -> u64
Returns the number of times this task has been polled.