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]

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: usize) -> 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: usize) -> 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, twice the core size as max size if none provided, 60 seconds keep_alive if none provided and the default naming (rusty_pool_{pool_number}) 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 or exceeds half the size of usize. This restriction exists because two counters (total workers and idle counters) are stored within one AtomicUsize.

Trait Implementations

impl Default for Builder[src]

fn default() -> Builder[src]

Returns the “default value” for a type. Read more

Auto Trait Implementations

impl RefUnwindSafe for Builder

impl Send for Builder

impl Sync for Builder

impl Unpin for Builder

impl UnwindSafe for Builder

Blanket Implementations

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

pub fn type_id(&self) -> TypeId[src]

Gets the TypeId of self. Read more

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

pub fn borrow(&self) -> &T[src]

Immutably borrows from an owned value. Read more

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

pub fn borrow_mut(&mut self) -> &mut T[src]

Mutably borrows from an owned value. Read more

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

pub fn from(t: T) -> T[src]

Performs the conversion.

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

pub fn into(self) -> U[src]

Performs the conversion.

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.

pub fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>[src]

Performs the conversion.

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.

pub fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>[src]

Performs the conversion.