Skip to main content

ThreadPool

Trait ThreadPool 

Source
pub trait ThreadPool:
    Clone
    + Send
    + Sync
    + RefUnwindSafe
    + UnwindSafe
    + Unpin {
    // Required methods
    fn threads(&self) -> usize;
    unsafe fn spawn_unchecked<'a, F, Fut, T>(
        &self,
        work: F,
    ) -> BoxFuture<'a, Result<T, Box<dyn Error + Send>>>
       where F: FnOnce() -> Fut + Send + 'a,
             Fut: Future<Output = T> + 'a,
             T: Send + 'a;

    // Provided method
    fn spawn<F, Fut, T>(
        &self,
        work: F,
    ) -> BoxFuture<'static, Result<T, Box<dyn Error + Send>>>
       where F: FnOnce() -> Fut + Send + 'static,
             Fut: Future<Output = T> + 'static,
             T: Send + 'static { ... }
}

Required Methods§

Source

fn threads(&self) -> usize

Source

unsafe fn spawn_unchecked<'a, F, Fut, T>( &self, work: F, ) -> BoxFuture<'a, Result<T, Box<dyn Error + Send>>>
where F: FnOnce() -> Fut + Send + 'a, Fut: Future<Output = T> + 'a, T: Send + 'a,

§Safety

Must be polled to completion before dropping. Unsound to forget it without having polled to completion.

Provided Methods§

Source

fn spawn<F, Fut, T>( &self, work: F, ) -> BoxFuture<'static, Result<T, Box<dyn Error + Send>>>
where F: FnOnce() -> Fut + Send + 'static, Fut: Future<Output = T> + 'static, T: Send + 'static,

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementations on Foreign Types§

Source§

impl<P> ThreadPool for &P
where P: ThreadPool + ?Sized,

Source§

fn threads(&self) -> usize

Source§

fn spawn<F, Fut, T>( &self, work: F, ) -> BoxFuture<'static, Result<T, Box<dyn Error + Send>>>
where F: FnOnce() -> Fut + Send + 'static, Fut: Future<Output = T> + 'static, T: Send + 'static,

Source§

unsafe fn spawn_unchecked<'a, F, Fut, T>( &self, work: F, ) -> BoxFuture<'a, Result<T, Box<dyn Error + Send>>>
where F: FnOnce() -> Fut + Send + 'a, Fut: Future<Output = T> + 'a, T: Send + 'a,

Implementors§