pub trait AbortableTask: Future<Output = Result<(), Box<dyn Error + Send>>> + Send {
// Required method
fn abort(&self);
}Expand description
A future that represents a running task which can be cancelled.
Awaiting an AbortableTask blocks until the task completes and yields
Ok(()) on success or an error if the task panicked or otherwise failed.
Call abort to request cancellation. The exact
semantics are runtime-dependent:
- Tokio — calls
JoinHandle::abort, which cancels the task at the next.awaitpoint. - std thread — drops the join handle and marks the task as finished so that awaiting the future resolves immediately. The underlying thread may continue running, but the caller is no longer blocked on it.
Required Methods§
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".