A lite thread pool library written for Rust.

Usage

Cargo.toml

toml [dependencies] poolite = "0.3.0" or toml [dependencies] poolite = { git = "https://github.com/biluohc/poolite",branch = "master", version = "0.3.0" }

Explain

Create a thread Pool:

The following are optional:

Let Pool to start run:

Add a task to the Pool:

Get Pool's status

Drop

Example

```Rust extern crate poolite;

use std::collections::BTreeMap; use std::sync::{Arc, Mutex}; use std::time::Duration; use std::thread;

fn main() { let pool = poolite::Pool::new().run(); let map = Arc::new(Mutex::new(BTreeMap::::new())); for i in 0..28 { let map = map.clone(); pool.spawn(Box::new(move || test(i, map))); } fn test(msg: i32, map: Arc>>) { let res = fib(msg); { let mut maplock = map.lock().unwrap(); maplock.insert(msg, res); } } fn fib(msg: i32) -> i32 { match msg { 0...2 => 1, x => fib(x - 1) + fib(x - 2), } } thread::sleep(Duration::from_millis(2000)); //wait for pool 2000ms for (k, v) in map.lock().unwrap().iter() { println!("key: {}\tvalue: {}", k, v); } } ```

ChangLog