3 releases

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

#1221 in Concurrency

Download history 2413/week @ 2024-07-19 1922/week @ 2024-07-26 2752/week @ 2024-08-02 2166/week @ 2024-08-09 2314/week @ 2024-08-16 2046/week @ 2024-08-23 2099/week @ 2024-08-30 2386/week @ 2024-09-06 2551/week @ 2024-09-13 3099/week @ 2024-09-20 1608/week @ 2024-09-27 2028/week @ 2024-10-04 1979/week @ 2024-10-11 1653/week @ 2024-10-18 1815/week @ 2024-10-25 1517/week @ 2024-11-01

7,267 downloads per month
Used in 59 crates (5 directly)

MIT license

21KB
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

~260KB