[][src]Trait threads_pool::PoolManager

pub trait PoolManager {
    fn extend(&mut self, more: usize);
fn shrink(&mut self, less: usize);
fn resize(&mut self, total: usize);
fn auto_adjust(&mut self);
fn auto_expire(&mut self, life: Option<Duration>);
fn kill_worker(&mut self, id: usize);
fn clear(&mut self);
fn close(&mut self);
fn force_close(&mut self); }

Required methods

fn extend(&mut self, more: usize)

fn shrink(&mut self, less: usize)

fn resize(&mut self, total: usize)

fn auto_adjust(&mut self)

fn auto_expire(&mut self, life: Option<Duration>)

fn kill_worker(&mut self, id: usize)

fn clear(&mut self)

fn close(&mut self)

fn force_close(&mut self)

Loading content...

Implementors

impl PoolManager for ThreadPool[src]

fn extend(&mut self, more: usize)[src]

Manually extend the size of the pool. If another operation that's already adding more threads to the pool, e.g. the pool is under pressure and trigger a pool extension automatically, then this operation will be cancelled.

fn shrink(&mut self, less: usize)[src]

Manually shrink the size of the pool and release system resources. If another operation that's reducing the size of the pool is undergoing, this shrink-op will be cancelled.

fn resize(&mut self, target: usize)[src]

Resize the pool to the desired size. This will either trigger a pool extension or contraction. Note that if another pool-size changing operation is undergoing, the effect may be cancelled out if we're moving towards the same direction (adding pool size, or reducing pool size).

fn auto_adjust(&mut self)[src]

Automatically adjust the pool size according to criteria: if the pool is idling and we've previously added temporary workers, we will tell them to cease work before designated expiration time; if the pool is overwhelmed and need more workers to handle jobs, we will add more threads to the pool.

fn auto_expire(&mut self, life: Option<Duration>)[src]

Let extended workers to expire when idling for too long.

fn kill_worker(&mut self, id: usize)[src]

Remove a thread worker from the pool with the given worker id.

fn clear(&mut self)[src]

Clear the pool. Note this will not kill all workers immediately, and the API will block until all workers have finished their current job. Note that this also means we may leave queued jobs in place until new threads are added into the pool, otherwise, the jobs will not be executed and go away on program exit.

fn close(&mut self)[src]

Signal the threads in the pool that we're closing, but allow them to finish all jobs in the queue before exiting.

fn force_close(&mut self)[src]

Signal the threads that they must quit now, and all queued jobs in the queue will be de-factor discarded since we're closing the pool.

Loading content...