Trait workpool::Pool

source ·
pub trait Pool<I> {
    type Output;
    type WaitHandle: WaitHandle<Output = Self::Output>;

    // Required methods
    fn add(&self, input: I);
    fn wait_handle(self) -> Self::WaitHandle;
    fn wait(self) -> Self::Output;
}
Expand description

Pool allows for parallel processing of items. When creating a pool a Worker and Reducer are provided. The worker accepts input and produces one output value for every input value. The reducer reduces the output from the worker into a single resulting value. Once created you can add input values to the pool using add(). Once all input has been added you can invoke either wait() or wait_handle() to wait for all input to be processed and retrieve the reduced output value.

Required Associated Types§

Required Methods§

source

fn add(&self, input: I)

source

fn wait_handle(self) -> Self::WaitHandle

source

fn wait(self) -> Self::Output

Implementors§

source§

impl<I, W, R> Pool<I> for DynamicPool<I, W, R>where W: Worker<I>, R: Reducer<W::Output>,

§

type Output = <R as Reducer<<W as Worker<I>>::Output>>::Output

§

type WaitHandle = WaitHandle<<R as Reducer<<W as Worker<I>>::Output>>::Output>

source§

impl<I, W, R> Pool<I> for StaticPool<I, W, R>where I: Send + 'static, W: Worker<I> + Send + Sync + 'static, R: Reducer<W::Output> + Send + 'static, R::Output: Send + Sync,

§

type Output = <R as Reducer<<W as Worker<I>>::Output>>::Output

§

type WaitHandle = WaitHandle<<R as Reducer<<W as Worker<I>>::Output>>::Output>