#threadpool

task_queue

The implementation of the thread pool for Rust

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

#14 in #threadpool

Download history 6/week @ 2021-06-04 18/week @ 2021-06-11 10/week @ 2021-06-18 6/week @ 2021-06-25 16/week @ 2021-07-02 26/week @ 2021-07-09 41/week @ 2021-07-16 14/week @ 2021-07-23 21/week @ 2021-07-30 17/week @ 2021-08-06 13/week @ 2021-08-13 11/week @ 2021-08-20 9/week @ 2021-08-27 2/week @ 2021-09-03 9/week @ 2021-09-10 7/week @ 2021-09-17

62 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();
}
# queue.stop_wait();

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
    }
}
#
# fn main() {
# }

No runtime deps