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

#18 in #threadpool

Download history 2/week @ 2024-08-31 4/week @ 2024-09-07 5/week @ 2024-09-14 19/week @ 2024-09-21 23/week @ 2024-09-28 8/week @ 2024-10-05 14/week @ 2024-10-12 9/week @ 2024-10-19 13/week @ 2024-10-26 8/week @ 2024-11-02 1/week @ 2024-11-09 1/week @ 2024-11-16 9/week @ 2024-11-23 6/week @ 2024-11-30 13/week @ 2024-12-07 44/week @ 2024-12-14

72 downloads per month

MIT license

30KB
708 lines

task_queue

The implementation of the thread pool for Rust.

Library supports dynamic control over the number of threads.

Documentation

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

No runtime deps