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§
sourcefn spawn_compute<F, R>(&self, func: F) -> AsyncRayonHandle<R> ⓘ
fn spawn_compute<F, R>(&self, func: F) -> AsyncRayonHandle<R> ⓘ
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.
sourcefn spawn_install_compute<F, R>(self: Arc<Self>, func: F) -> AsyncRayonHandle<R> ⓘ
fn spawn_install_compute<F, R>(self: Arc<Self>, func: F) -> AsyncRayonHandle<R> ⓘ
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
.