[][src]Trait futures_cputask::AsyncThreadPool

pub trait AsyncThreadPool {
    fn new() -> Self;
fn with_thread_count(num_threads: usize) -> Self;
fn execute<F, T>(
        &self,
        fun: F
    ) -> Pin<Box<dyn Future<Output = T> + Send + Sync + 'static>>
    where
        F: FnOnce() -> T + Send + 'static,
        T: Sized + Send + Sync + 'static
; }

Asynchronous threadpools

This trait specifies an interface for interacting with asynchronous threadpools, which allow you to await jobs

Required methods

fn new() -> Self

Create a new default thread pool

The implementor is suggested to dynamically check the amount of processing units available and spawn that many threads for threadpool usage.

fn with_thread_count(num_threads: usize) -> Self

Creates a new thread pool with a maximum of num_threads threads

The implementor shall not execute more than num_threads jobs at the same time, unless modified. Internal threads that manage the job threads are not counted towards that limit.

fn execute<F, T>(
    &self,
    fun: F
) -> Pin<Box<dyn Future<Output = T> + Send + Sync + 'static>> where
    F: FnOnce() -> T + Send + 'static,
    T: Sized + Send + Sync + 'static, 

Schedules a task on the threadpool

As soon as the task is scheduled, this function shall return a future.

Loading content...

Implementors

impl<P> AsyncThreadPool for ThreadPool<P> where
    P: SyncThreadPool + Sized
[src]

Loading content...