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

#1213 in Concurrency

Download history 68/week @ 2024-07-22 35/week @ 2024-07-29 41/week @ 2024-08-05 35/week @ 2024-08-12 31/week @ 2024-08-19 99/week @ 2024-08-26 23/week @ 2024-09-02 17/week @ 2024-09-09 45/week @ 2024-09-16 57/week @ 2024-09-23 32/week @ 2024-09-30 3/week @ 2024-10-07 19/week @ 2024-10-14 23/week @ 2024-10-21 9/week @ 2024-10-28 27/week @ 2024-11-04

78 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

~2MB
~45K SLoC