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

#961 in Concurrency

Download history 1/week @ 2023-11-20 2/week @ 2023-11-27 1/week @ 2023-12-04 22/week @ 2023-12-11 16/week @ 2023-12-18 6/week @ 2024-01-22 10/week @ 2024-02-12 53/week @ 2024-02-19 45/week @ 2024-02-26 29/week @ 2024-03-04

137 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