7 releases

Uses old Rust 2015

0.1.5 Aug 19, 2019
0.1.4 Jan 19, 2018
0.1.0 Dec 20, 2017
0.0.1 Dec 19, 2017

#894 in Concurrency

Download history 100/week @ 2024-03-29 49/week @ 2024-04-05 47/week @ 2024-04-12 57/week @ 2024-04-19 58/week @ 2024-04-26 54/week @ 2024-05-03 53/week @ 2024-05-10 43/week @ 2024-05-17 49/week @ 2024-05-24 47/week @ 2024-05-31 31/week @ 2024-06-07 86/week @ 2024-06-14 58/week @ 2024-06-21 17/week @ 2024-06-28 9/week @ 2024-07-05 29/week @ 2024-07-12

125 downloads per month
Used in 12 crates (via fibers_tasque)

MIT license

16KB
331 lines

tasque

Documentation Build Status Code Coverage License: MIT

A simple thread pool library for Rust.

Documentation


lib.rs:

A simple thread pool library for Rust.

Examples

Basic usage:

use std::sync::mpsc;
use std::thread;
use std::time::Duration;
use tasque::TaskQueueBuilder;

// Creates a task queue.
// This queue spawns worker threads for executing tasks.
let queue = TaskQueueBuilder::new().worker_count(3).finish();

// Executes asynchronous tasks.
let (tx, rx) = mpsc::channel();
for (i, tx) in (0..3).map(|i| (i, tx.clone())) {
    queue.enqueue(move || {
        thread::sleep(Duration::from_millis(20 - i * 10));
        let _ = tx.send(i);
    });
}

// Waits results.
assert_eq!(rx.recv().ok(), Some(2));
assert_eq!(rx.recv().ok(), Some(1));
assert_eq!(rx.recv().ok(), Some(0));

Dependencies

~1.4–1.8MB
~43K SLoC