pub trait Executor: Send + Sync {
type Task<T: Send + 'static>: Task<T> + Send;
// Required method
fn spawn<Fut>(&self, fut: Fut) -> Self::Task<Fut::Output>
where Fut: Future<Output: Send> + Send + 'static;
}Expand description
A trait for spawning Send + 'static futures.
This trait is implemented by runtime-agnostic executors that can spawn futures
across thread boundaries. The spawned futures must be Send and 'static.
The 'static lifetime requirements come from the underlying async runtimes
(like Tokio) which need to ensure memory safety when tasks are moved across
threads and may outlive their spawning scope.
See AnyExecutor for a type-erased executor.
Required Associated Types§
Required Methods§
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.
Implementations on Foreign Types§
Implementors§
Source§impl Executor for AnyExecutor
impl Executor for AnyExecutor
type Task<T: Send + 'static> = AnyExecutorTask<T>
Source§impl Executor for DefaultExecutor
Available on crate feature std only.
impl Executor for DefaultExecutor
Available on crate feature
std only.