pub trait ExecutorBlocking: Executor {
// Required method
fn spawn_blocking<F, R>(&self, f: F) -> JoinHandle<R> ⓘ
where F: FnOnce() -> R + Send + 'static,
R: Send + 'static;
// Provided method
fn spawn_blocking_abortable<F, R>(&self, f: F) -> AbortableJoinHandle<R> ⓘ
where F: FnOnce() -> R + Send + 'static,
R: Send + 'static { ... }
}Required Methods§
Sourcefn spawn_blocking<F, R>(&self, f: F) -> JoinHandle<R> ⓘ
fn spawn_blocking<F, R>(&self, f: F) -> JoinHandle<R> ⓘ
Spawn a thread in the background with the ability to concurrently await on the results without blocking the executor.
Note that there is no real way to abort the thread, and calling JoinHandle::abort
would only abort the underlining tasked that is being polled but not the thread itself.
Provided Methods§
Sourcefn spawn_blocking_abortable<F, R>(&self, f: F) -> AbortableJoinHandle<R> ⓘ
fn spawn_blocking_abortable<F, R>(&self, f: F) -> AbortableJoinHandle<R> ⓘ
Spawns a thread in the background, returning an abortable handle that will cancel it once the handle is dropped.
Note: This function is used if the task is expected to run until the handle is dropped.
It is recommended to use ExecutorBlocking::spawn_blocking. Additionally, there is no guarantee
that the thread will cancel or abort.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".