- Create a thread pool to run your code
- Use log crate to print log
- [TODO] Support different scheduling algorithm
use rust_pool::ThreadPool;
// Create new ThreadPool let mut new_pool = match ThreadPool::new(5) { Ok(pool) => pool, Err(_) => { panic!("Create new ThreadPool error"); }, };
// Add your code to the pool for i in 0..8 { match new_pool.push_task(move || { println!("Task {} is running...", i); }) { Err(err) => { panic!(err); }, _ => {}, } }
// Execute the pool match new_pool.execute() { Ok(_) => {}, Err(err) => panic!(err), }
See more details in example/src/main.rs
- random-number = "0.1.3"
- log = "0.4.11"
- Add algorithm module for supporting different scheduling algorithm
pub use pool::*; |
config | Config of Rust Thread Pool |
cookie_generator | Cookie Generator to generate a unique cookie |
error | Error Handler for Rust Thread Pool |
pool | Thread Pool Implement |
signal | Signal Implement |
task | Task Implement |
worker | Worker Implement |
Run cargo doc --open
to read the docment.