3 releases

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

#760 in Concurrency

Download history 3716/week @ 2024-03-14 3054/week @ 2024-03-21 2606/week @ 2024-03-28 4088/week @ 2024-04-04 4199/week @ 2024-04-11 3726/week @ 2024-04-18 2519/week @ 2024-04-25 3178/week @ 2024-05-02 3396/week @ 2024-05-09 2983/week @ 2024-05-16 2462/week @ 2024-05-23 2512/week @ 2024-05-30 3289/week @ 2024-06-06 2482/week @ 2024-06-13 2648/week @ 2024-06-20 1917/week @ 2024-06-27

10,934 downloads per month
Used in 55 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