Struct blocking_permit::DispatchPoolBuilder [−][src]
pub struct DispatchPoolBuilder { /* fields omitted */ }
Expand description
A builder for DispatchPool
supporting an extenstive set of
configuration options.
Implementations
Create new dispatch pool builder, for configuration.
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.
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)
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
Set the stack size in bytes for each thread in the pool.
Default: the default thread stack size.
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.
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
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
Create a new DispatchPool
with the provided configuration.