pub struct DynamicPool<I, W, R>where
    W: Worker<I>,
    R: Reducer<W::Output>,{ /* private fields */ }
Expand description

DynamicPool is a Pool that can dynamically adjust the number of threads at runtime.

Implementations§

source§

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

source

pub fn set_concurrency_limit(&self, concurrency_limit: i64)

Adjust the concurrency_limit. Only this many work items will be processed concurrently. If the pool is currently processing more than the new limit’s amount of work the current work will finish processing until the amount of concurrenct work drops below the new threshold.

source

pub fn add(&self, input: I)

Add a work item to be done by the pool.

source

pub fn wait_handle(self) -> WaitHandle<R::Output>

Return a wait handle. This indicates that no new work will be added to the pool and wait() can be invoked on the returned handle to wait for all input to be processed and retrieve the output value.

source

pub fn wait(self) -> R::Output

Wait for all input to be processed and return the output value.

Trait Implementations§

source§

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

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
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§

fn add(&self, input: I)

source§

fn wait_handle(self) -> Self::WaitHandle

source§

fn wait(self) -> R::Output

Auto Trait Implementations§

§

impl<I, W, R> !RefUnwindSafe for DynamicPool<I, W, R>

§

impl<I, W, R> Send for DynamicPool<I, W, R>where I: Send, <R as Reducer<<W as Worker<I>>::Output>>::Output: Send + Sync,

§

impl<I, W, R> Sync for DynamicPool<I, W, R>where I: Send, <R as Reducer<<W as Worker<I>>::Output>>::Output: Send + Sync,

§

impl<I, W, R> Unpin for DynamicPool<I, W, R>

§

impl<I, W, R> !UnwindSafe for DynamicPool<I, W, R>

Blanket Implementations§

source§

impl<T> Any for Twhere T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for Twhere T: ?Sized,

const: unstable · source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere T: ?Sized,

const: unstable · source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

const: unstable · source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for Twhere U: From<T>,

const: unstable · source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T, U> TryFrom<U> for Twhere U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
const: unstable · source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for Twhere U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
const: unstable · source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.