Struct rusty_pool::Builder [−][src]
pub struct Builder { /* fields omitted */ }
A helper struct to aid creating a new ThreadPool
using default values where no value was
explicitly specified.
Implementations
impl Builder
[src]
impl Builder
[src]pub fn new() -> Builder
[src]
Create a new Builder
.
pub fn name(self, name: String) -> Builder
[src]
Specify the name of the ThreadPool
that will be used as prefix for the name of each worker thread.
By default the name is “rusty_pool_x” with x being a static pool counter.
pub fn core_size(self, size: u32) -> Builder
[src]
Specify the core pool size for the ThreadPool
. The core pool size is the number of threads that stay alive
for the entire lifetime of the ThreadPool
or, to be more precise, its channel. These threads are spawned if
a task is submitted to the ThreadPool
and the current worker count is below the core pool size.
pub fn max_size(self, size: u32) -> Builder
[src]
Specify the maximum pool size this ThreadPool
may scale up to. This numbers represents the maximum number
of threads that may be alive at the same time within this pool. Additional threads above the core pool size
only remain idle for the duration specified by the keep_alive
parameter before terminating. If the core pool
is full, the current pool size is below the max size and there are no idle threads then additional threads
will be spawned.
pub fn keep_alive(self, keep_alive: Duration) -> Builder
[src]
Specify the duration for which additional threads outside the core pool remain alive while not receiving any work before giving up and terminating.
pub fn build(self) -> ThreadPool
[src]
Build the ThreadPool
using the parameters previously supplied to this Builder
using the number of CPUs as
default core size if none provided, 4 times the core size as max size if none provided, 60 seconds keep_alive
if none provided and the default naming if none provided. This function calls ThreadPool::new
or ThreadPool::new_named
depending on whether a name was provided.
Panics
Building might panic if the max_size
is 0 or lower than core_size
: