Struct thread_pool::Builder
[−]
[src]
pub struct Builder { /* fields omitted */ }
Thread pool configuration.
Provide detailed control over the properties and behavior of the thread pool.
Methods
impl Builder
[src]
fn new() -> Builder
Returns a builder with default values
fn core_pool_size(self, val: usize) -> Self
Set the thread pool's core size.
The number of threads to keep in the pool, even if they are idle.
fn max_pool_size(self, val: usize) -> Self
Set the thread pool's maximum size
The maximum number of threads to allow in the pool.
fn keep_alive(self, val: Duration) -> Self
Set the thread keep alive duration
When the number of threads is greater than core target or core threads are allowed to timeout, this is the maximum time that idle threads will wait for new tasks before terminating.
fn allow_core_thread_timeout(self) -> Self
Allow core threads to timeout
fn work_queue_capacity(self, val: usize) -> Self
Maximum number of jobs that can be pending in the work queue
fn name_prefix<S: Into<String>>(self, val: S) -> Self
Set name prefix of threads spawned by the pool
Thread name prefix is used for generating thread names. For example, if
prefix is my-pool-
, then threads in the pool will get names like
my-pool-1
etc.
fn stack_size(self, val: usize) -> Self
Set the stack size of threads spawned by the pool
fn after_start<F>(self, f: F) -> Self where
F: Fn() + Send + Sync + 'static,
F: Fn() + Send + Sync + 'static,
Execute function f
right after each thread is started but before
running any tasks on it
This is initially intended for bookkeeping and monitoring uses
fn before_stop<F>(self, f: F) -> Self where
F: Fn() + Send + Sync + 'static,
F: Fn() + Send + Sync + 'static,
Execute function f
before each worker thread stops
This is initially intended for bookkeeping and monitoring uses
fn build<T: Task>(self) -> (Sender<T>, ThreadPool<T>)
Build and return the configured thread pool