pub struct TaskCompletion<R, E> { /* private fields */ }Expand description
Completion endpoint owned by a task runner.
This low-level endpoint is exposed so custom executor services built on top
of qubit-executor can wire their own scheduling and cancellation hooks
while still returning the standard crate::TaskHandle. Normal callers
should use crate::TaskHandle and executor/service submission methods
instead.
Implementations§
Source§impl<R, E> TaskCompletion<R, E>
impl<R, E> TaskCompletion<R, E>
Sourcepub fn start(&self) -> bool
pub fn start(&self) -> bool
Marks the task as started if it was not cancelled first.
§Returns
true if the runner should execute the task, or false if the task was
already completed through cancellation.
Sourcepub fn complete(&self, result: TaskResult<R, E>)
pub fn complete(&self, result: TaskResult<R, E>)
Completes the task with its final result.
If another path has already completed the task, this result is ignored.
§Parameters
result- Final task result to publish if the task is not already completed.
Sourcepub fn start_and_complete<F>(&self, task: F) -> boolwhere
F: FnOnce() -> TaskResult<R, E>,
pub fn start_and_complete<F>(&self, task: F) -> boolwhere
F: FnOnce() -> TaskResult<R, E>,
Starts the task and completes it with a lazily produced result.
The supplied closure is executed only if this completion endpoint wins the start race. If the handle was cancelled first, the closure is not called and the existing cancellation result is preserved.
§Parameters
task- Closure that runs the accepted task and returns its final result.
§Returns
true if the closure was executed and its result was published, or
false if the task had already been completed by cancellation.