A lite thread pool library written for Rust.
Usage
Cargo.toml
[]
= "0.2.0"
or
[]
= { = "https://github.com/biluohc/poolite", = "master", = "0.2.0" }
Explain
Create a thread pool:
- use
poolite::pool::new()create a thread_pool.
The following are optional:
min()receiveusizeas minimum number of threads in pool,default is cpu's number.time_out()receiveu64as thread's idle time(ms) except minimum number of threads,default is 5000(ms).name()receive&stras thread's name,default is None.stack_size()receiveusizeas thread's stack_size,default depends on OS.
Let thread pool to start run:
run()let pool to start run.
Add a task to the thread pool:
spawn()receiveBox<FnMut() + Send>.- while leave scope,pool will drop automatically.
Example
extern crate poolite;
use Duration;
use thread;