Trait Executor

Source
pub trait Executor {
    // Required method
    fn spawn<T: Send + 'static>(
        &self,
        fut: impl Future<Output = T> + Send + 'static,
    ) -> impl Task<Output = T>;
}
Expand description

A trait for executor implementations that can spawn thread-safe futures.

This trait represents executors capable of running concurrent tasks that are Send, meaning they can be safely moved between threads. Implementors provide the core functionality for task spawning in a multi-threaded context.

Required Methods§

Source

fn spawn<T: Send + 'static>( &self, fut: impl Future<Output = T> + Send + 'static, ) -> impl Task<Output = T>

Spawns a thread-safe future on this executor.

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§

Source§

impl Executor for Executor<'static>

Source§

fn spawn<T: Send + 'static>( &self, fut: impl Future<Output = T> + Send + 'static, ) -> impl Task<Output = T>

Source§

impl Executor for Runtime

Source§

fn spawn<T: Send + 'static>( &self, fut: impl Future<Output = T> + Send + 'static, ) -> impl Task<Output = T>

Implementors§