#thread #pool #scoped #threadpool

yastl

Yet another scoped threadpool library

3 releases

0.1.2 Feb 25, 2021
0.1.1 Feb 25, 2021
0.1.0 Feb 23, 2021

#114 in Concurrency

Download history 163/week @ 2021-04-06 129/week @ 2021-04-13 126/week @ 2021-04-20 121/week @ 2021-04-27 101/week @ 2021-05-04 61/week @ 2021-05-11 7/week @ 2021-05-18 8/week @ 2021-05-25 8/week @ 2021-06-01 17/week @ 2021-06-08 58/week @ 2021-06-15 29/week @ 2021-06-22 116/week @ 2021-06-29 139/week @ 2021-07-06 40/week @ 2021-07-13 37/week @ 2021-07-20

499 downloads per month

MIT license

20KB
432 lines

yastl

Crates.io Documentation

Yet another scoped threadpool library for Rust.

yastl is heavily inspired by the scoped_threadpool and scoped_pool crates. It is mostly a port to modern Rust of the scoped_pool crate

Example

use yastl::Pool;

fn main() {
    let pool = Pool::new(4);
    let mut list = vec![1, 2, 3, 4, 5];

    pool.scoped(|scope| {
        // since the `scope` guarantees that the threads are finished if it drops,
        // we can safely borrow `list` inside here.
        for x in list.iter_mut() {
            scope.execute(move || {
                *x += 2;
            });
        }
    });

    assert_eq!(list, vec![3, 4, 5, 6, 7]);
}

Feature Flags

  • coz: Enable support for the coz profiler. Calls coz::thread_init() in every new thread.

License

Licensed under the MIT license.

Dependencies

~265KB