Trait zappot::util::tokio_rayon::AsyncThreadPool

source ·
pub trait AsyncThreadPool: Sealed {
    // Required methods
    fn spawn_compute<F, R>(&self, func: F) -> AsyncRayonHandle<R> 
       where F: FnOnce() -> R + Send + 'static,
             R: Send + 'static;
    fn spawn_install_compute<F, R>(
        self: Arc<Self>,
        func: F
    ) -> AsyncRayonHandle<R> 
       where F: FnOnce() -> R + Send + 'static,
             R: Send + 'static;
}

Required Methods§

source

fn spawn_compute<F, R>(&self, func: F) -> AsyncRayonHandle<R>
where F: FnOnce() -> R + Send + 'static, R: Send + 'static,

Asynchronous wrapper around Rayon’s ThreadPool::spawn.

Runs a function on the global Rayon thread pool with LIFO priority, produciing a future that resolves with the function’s return value.

§Panics

If the task function panics, the panic will be propagated through the returned future. This will NOT trigger the Rayon thread pool’s panic handler.

If the returned handle is dropped, and the return value of func panics when dropped, that panic WILL trigger the thread pool’s panic handler.

source

fn spawn_install_compute<F, R>(self: Arc<Self>, func: F) -> AsyncRayonHandle<R>
where F: FnOnce() -> R + Send + 'static, R: Send + 'static,

This is a combination of ThreadPool::spawn and ThreadPool::install. This means, that not only the passed closure is run on the threadpool, but also all calls to parallel iterators which are performed by the closure.

In order to support this, the ThreadPool must be inside an Arc.

Object Safety§

This trait is not object safe.

Implementations on Foreign Types§

source§

impl AsyncThreadPool for ThreadPool

source§

fn spawn_compute<F, R>(&self, func: F) -> AsyncRayonHandle<R>
where F: FnOnce() -> R + Send + 'static, R: Send + 'static,

source§

fn spawn_install_compute<F, R>(self: Arc<Self>, func: F) -> AsyncRayonHandle<R>
where F: FnOnce() -> R + Send + 'static, R: Send + 'static,

Implementors§