Skip to main content

ThreadPooler

Trait ThreadPooler 

Source
pub trait ThreadPooler: Spawner + Metrics {
    // Required method
    fn create_thread_pool(
        &self,
        concurrency: NonZeroUsize,
    ) -> Result<ThreadPool, ThreadPoolBuildError>;

    // Provided method
    fn create_strategy(
        &self,
        concurrency: NonZeroUsize,
    ) -> Result<Rayon, ThreadPoolBuildError> { ... }
}
Expand description

Trait for creating rayon-compatible thread pools with each worker thread placed on dedicated threads via Spawner.

Required Methods§

Source

fn create_thread_pool( &self, concurrency: NonZeroUsize, ) -> Result<ThreadPool, ThreadPoolBuildError>

Creates a clone-able rayon-compatible thread pool with Spawner::spawn.

§Arguments
  • concurrency: The number of tasks to execute concurrently in the pool.
§Returns

A Result containing the configured rayon::ThreadPool or a rayon::ThreadPoolBuildError if the pool cannot be built.

Provided Methods§

Source

fn create_strategy( &self, concurrency: NonZeroUsize, ) -> Result<Rayon, ThreadPoolBuildError>

Creates a clone-able Rayon strategy for use with commonware_parallel.

§Arguments
  • concurrency: The number of tasks to execute concurrently in the pool.
§Returns

A Result containing the configured Rayon strategy or a rayon::ThreadPoolBuildError if the pool cannot be built.

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.

Implementors§

Source§

impl ThreadPooler for commonware_runtime::deterministic::Context

Source§

impl ThreadPooler for commonware_runtime::tokio::Context

Available on neither commonware_stability_GAMMA nor commonware_stability_DELTA nor commonware_stability_EPSILON nor commonware_stability_RESERVED.
Source§

impl<C> ThreadPooler for Cell<C>
where C: ThreadPooler,

Available on neither commonware_stability_GAMMA nor commonware_stability_DELTA nor commonware_stability_EPSILON nor commonware_stability_RESERVED.