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]
fn num_cpus() -> usize
[src]
fn new() -> Self
[src]
fn name<S>(self, name: S) -> Self where
S: Debug + Into<String>,
[src]
S: Debug + Into<String>,
Sets thread's name where them in the Pool,default is None('<unnamed>'
).
fn name_get(&self) -> Option<&String>
[src]
fn stack_size(self, size: usize) -> Self
[src]
Sets thread's stack_size where them in the Pool,default depends on OS.
fn stack_size_get(&self) -> Option<&usize>
[src]
fn min(self, min: usize) -> Self
[src]
Sets the minimum number of threads in the Pool,default is num_cpus()+1
.
fn min_get(&self) -> &usize
[src]
fn max(self, max: usize) -> Self
[src]
Sets the maximum number of threads in the Pool,default is (num_cpus()+1)*num_cpus()
.
fn max_get(&self) -> &usize
[src]
fn timeout_ms(self, timeout: Option<u64>) -> Self
[src]
Sets thread's idle time(ms) except minimum number of threads,default is 5000(ms).
fn timeout(self, timeout: Option<Duration>) -> Self
[src]
fn timeout_get(&self) -> Option<&Duration>
[src]
fn daemon_ms(self, daemon: Option<u64>) -> Self
[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.
fn daemon(self, daemon: Option<Duration>) -> Self
[src]
fn daemon_get(&self) -> Option<&Duration>
[src]
fn load_limit(self, load_limit: usize) -> Self
[src]
Sets the value of load_limit for the Pool.
default is num_cpus() * num_cpus()
.