Struct poolite::Builder [] [src]

pub struct Builder { /* fields omitted */ }

Pool's Settings

extern crate poolite;
use poolite::Builder;

/// `cargo run --example without`
fn main() {
    let pool = Builder::new()
    .min(2)
    .max(9)
    .daemon(None)  // Close daemon
    .timeout(None) // Close timeout
    .name("Worker")
    .stack_size(1024*1024*2) //2Mib
    .build()
    .unwrap();

    for i in 0..33 {
        pool.push(move || test(i));
    }

    pool.join(); //wait for the pool
    println!("{:?}", pool);
}

fn test(msg: i32) {
    println!("key: {}\tvalue: {}", msg, fib(msg));
}

fn fib(msg: i32) -> i32 {
    match msg {
        0...2 => 1,
        x => fib(x - 1) + fib(x - 2),
    }
}

Methods

impl Builder
[src]

[src]

[src]

[src]

Sets thread's name where them in the Pool,default is None('<unnamed>').

[src]

[src]

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

[src]

[src]

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

[src]

[src]

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

[src]

[src]

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

[src]

[src]

[src]

Sets whether to open the daemon for the Pool, the default is Some(5000)(thread's default idle time(ms)).

You can use None to close.

[src]

[src]

[src]

Sets the value of load_limit for the Pool.

default is num_cpus() * num_cpus().

[src]

[src]

Trait Implementations

impl Debug for Builder
[src]

[src]

Formats the value using the given formatter.

impl Default for Builder
[src]

[src]

Returns the "default value" for a type. Read more