[][src]Struct blocking_permit::DispatchPoolBuilder

pub struct DispatchPoolBuilder { /* fields omitted */ }

A builder for DispatchPool supporting an extenstive set of configuration options.

Methods

impl DispatchPoolBuilder[src]

pub fn new() -> DispatchPoolBuilder[src]

Create new dispatch pool builder, for configuration.

pub fn pool_size(&mut self, size: usize) -> &mut Self[src]

Set the fixed number of threads in the pool.

This must at least be one (1) thread, asserted. However the value is ignored (and no threads are spawned) if queue_length is zero (0).

Default: the number of logical CPU's minus one, but one at minimum:

Detected CPUsDefault Pool Size
01
11
21
32
43

Detected CPUs may be influenced by simultaneous multithreading (SMT, e.g. Intel hyper-threading) or scheduler affinity. Zero (0) detected CPUs is likely an error.

pub fn queue_length(&mut self, length: usize) -> &mut Self[src]

Set the length (aka maximum capacity or depth) of the associated dispatch task queue.

The length may be zero, in which case the pool is always considered full and no threads are spawned. If the queue is ever full, tasks will be executed on the calling thread, see DispatchPool::spawn.

Default: unbounded (unlimited)

pub fn ignore_panics(&mut self, ignore: bool) -> &mut Self[src]

Set whether to catch and ignore unwinds for dispatch tasks that panic, or to abort.

When true, panics are ignored. Note that the unwind safety of dispatched tasks is not well assured by the UnwindSafe marker trait and may later result in undefined behavior (UB) or logic bugs.

If false, a panic in a dispatch pool thread will result in process abort.

Default: false

pub fn stack_size(&mut self, stack_size: usize) -> &mut Self[src]

Set the stack size in bytes for each thread in the pool.

Default: the default thread stack size.

pub fn name_prefix<S: Into<String>>(&mut self, name_prefix: S) -> &mut Self[src]

Set name prefix for threads in the pool.

The (unique) thread index is appended to form the complete thread name.

Default: "dpx-pool-N-" where N is a 0-based global pool counter.

pub fn after_start<F>(&mut self, f: F) -> &mut Self where
    F: Fn(usize) + Send + Sync + 'static, 
[src]

Set a closure to be called immediately after each thread is started.

The closure is passed a 0-based index of the thread.

Default: None

pub fn before_stop<F>(&mut self, f: F) -> &mut Self where
    F: Fn(usize) + Send + Sync + 'static, 
[src]

Set a closure to be called immediately before a pool thread exits.

The closure is passed a 0-based index of the thread.

Default: None

pub fn create(&mut self) -> DispatchPool[src]

Create a new DispatchPool with the provided configuration.

Trait Implementations

impl Default for DispatchPoolBuilder[src]

Auto Trait Implementations

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

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

The type returned in the event of a conversion error.