3 releases

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

#829 in Concurrency

Download history 2095/week @ 2023-12-14 1650/week @ 2023-12-21 1659/week @ 2023-12-28 2787/week @ 2024-01-04 3293/week @ 2024-01-11 3090/week @ 2024-01-18 2859/week @ 2024-01-25 2411/week @ 2024-02-01 2577/week @ 2024-02-08 3654/week @ 2024-02-15 2857/week @ 2024-02-22 3452/week @ 2024-02-29 2660/week @ 2024-03-07 3716/week @ 2024-03-14 3054/week @ 2024-03-21 1947/week @ 2024-03-28

12,040 downloads per month
Used in 54 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