7 releases
Uses old Rust 2015
0.0.7 | Jul 8, 2017 |
---|---|
0.0.6 | Jul 9, 2016 |
0.0.5 | Jun 5, 2016 |
0.0.4 | May 10, 2016 |
0.0.3 | Feb 17, 2016 |
#16 in #threadpool
44 downloads per month
30KB
708 lines
task_queue
The implementation of the thread pool for Rust.
Library supports dynamic control over the number of threads.
Usage
Add this to your Cargo.toml:
[dependencies]
task_queue = "0.0.7"
and this to your crate root:
extern crate task_queue;
Example
extern crate task_queue;
let mut queue = task_queue::TaskQueue::new();
for _ in 0..10 {
queue.enqueue(|| {
println!("Hi from pool")
}).unwrap();
}
queue.stop_wait();
lib.rs
:
Task queue The implementation of the thread pool for Rust.
Example
extern crate task_queue;
let mut queue = task_queue::TaskQueue::new();
for _ in 0..10 {
queue.enqueue(|| {
println!("Hi from pool")
}).unwrap();
}
Library supports dynamic control over the number of threads. For implement it you should use SpawnPolicy trait.
For example StaticSpawnPolicy implementation:
Example
use task_queue::TaskQueueStats;
use task_queue::spawn_policy::SpawnPolicy;
pub struct StaticSpawnPolicy;
impl SpawnPolicy for StaticSpawnPolicy {
fn get_count(&mut self, stats: TaskQueueStats) -> usize {
stats.threads_max
}
}
#