Struct poolite::Pool [] [src]

pub struct Pool { /* fields omitted */ }

Pool struct.

Methods

impl Pool
[src]

Creates and returns a Pool.

Returns the number of CPUs of the current machine.

You can use it on min() or load_limit().

Sets whether to open the daemon for the Pool, the default is true。

Returns the value of daemon().

Sets the minimum number of threads in the Pool,default is num_cpus()+1.

Returns the value of the minimum number of threads in the Pool.

Sets thread's idle time(ms) except minimum number of threads,default is 5000(ms).

Returns the value of the thread's idle time(Duration).

Sets thread's name where them in the Pool,default is None.

Returns thread's name.

Sets thread's stack_size where them in the Pool,default depends on OS.

Returns thread's stack_size.

Sets the value of load_limit for the Pool,

pool will create new thread while tasks_queue_len()/threads bigger than it,default is cpu's number.

Warning: Pool maybe block when min() is 0 and load_limit() is'not 0,until tasks_queue_len()/threads bigger than load_limit.

Returns the value of load_limit.

Complete Example for Creating and Settings:

extern crate poolite;
use poolite::Pool;

let pool = Pool::new()
    .daemon(true)
    .min(Pool::num_cpus() + 1)
    .time_out(5000) //5000ms
    .name("name")
    .stack_size(2 * 1024 * 1024) //2MiB
    .load_limit(Pool::num_cpus())
    .run();

Running and adding tasks

Lets the Pool to start running(Add the number of min threads to the pool).

Adds a task to the Pool,

it receives Box<Fn() + Send + 'static>,Box<FnMut() + Send + 'static> and

Box<FnOnce() + Send + 'static>(Box<FnBox() + Send + 'static>).

Status

All threads are waiting and tasks_queue'length is 0.

Returns the length of the tasks_queue.

Approximately equal to len().

Returns the thread'number in the Pool.

Returns the thread'number that is waiting in the Pool

Trait Implementations

impl Drop for Pool
[src]

A method called when the value goes out of scope. Read more