Trait oxidd_core::WorkerManager

source ·
pub trait WorkerManager: Manager + Sync {
    // Required methods
    fn current_num_threads(&self) -> usize;
    fn join<RA: Send, RB: Send>(
        &self,
        op_a: impl FnOnce() -> RA + Send,
        op_b: impl FnOnce() -> RB + Send,
    ) -> (RA, RB);
    fn broadcast<R: Send>(
        &self,
        op: impl Fn(BroadcastContext) -> R + Sync,
    ) -> Vec<R>;
}
Expand description

Manager that also has a thread pool

A manager having its own thread pool has the advantage that it may use thread-local storage for its workers to pre-allocate some resources (e.g. slots for nodes) and thereby reduce lock contention.

Required Methods§

source

fn current_num_threads(&self) -> usize

Get the current number of threads

source

fn join<RA: Send, RB: Send>( &self, op_a: impl FnOnce() -> RA + Send, op_b: impl FnOnce() -> RB + Send, ) -> (RA, RB)

Execute op_a and op_b in parallel

source

fn broadcast<R: Send>( &self, op: impl Fn(BroadcastContext) -> R + Sync, ) -> Vec<R>

Execute op on every worker in the thread pool

Object Safety§

This trait is not object safe.

Implementors§