[−][src]Struct blocking_permit::DispatchPoolBuilder
A builder for DispatchPool
supporting an extenstive set of
configuration options.
Implementations
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 CPUs | Default Pool Size |
---|---|
0 | 1 |
1 | 1 |
2 | 1 |
3 | 2 |
4 | 3 |
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, the
oldest 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.
If 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]
F: Fn(usize) + Send + Sync + 'static,
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]
F: Fn(usize) + Send + Sync + 'static,
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
impl !RefUnwindSafe for DispatchPoolBuilder
[src]
impl Send for DispatchPoolBuilder
[src]
impl Sync for DispatchPoolBuilder
[src]
impl Unpin for DispatchPoolBuilder
[src]
impl !UnwindSafe for DispatchPoolBuilder
[src]
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
pub fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
pub fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,