Trait SyncThreadPool

Source
pub trait SyncThreadPool {
    // Required methods
    fn new() -> Self;
    fn with_thread_count(num_threads: usize) -> Self;
    fn execute<F>(&self, fun: F)
       where F: FnOnce() + Send + 'static;
}
Expand description

ThreadPool trait

SyncThreadPool has to be implemented for any kind of underlying threadpool you want to use with this crate. It defines the minimum interface required to be useful.

This crate implements this trait on the threadpool and uvth crates, if their corresponding features are enabled.

Required Methods§

Source

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.

Source

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.

Source

fn execute<F>(&self, fun: F)
where F: FnOnce() + Send + 'static,

Schedules a task on the threadpool

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

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 SyncThreadPool for ThreadPool

Source§

fn new() -> Self

Source§

fn with_thread_count(num_threads: usize) -> Self

Source§

fn execute<F>(&self, fun: F)
where F: FnOnce() + Send + 'static,

Source§

impl SyncThreadPool for ThreadPool

Source§

fn new() -> Self

Source§

fn with_thread_count(num_threads: usize) -> Self

Source§

fn execute<F>(&self, fun: F)
where F: FnOnce() + Send + 'static,

Implementors§