Crate task_queue [] [src]

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
    }
}

Modules

error

TaskQueue error.

spawn_policy

Trait that controls the number of threads.

Structs

Task
TaskQueue
TaskQueueStats