3 releases

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

#804 in Concurrency

Download history 3286/week @ 2024-01-15 2946/week @ 2024-01-22 2592/week @ 2024-01-29 2489/week @ 2024-02-05 3076/week @ 2024-02-12 3081/week @ 2024-02-19 3389/week @ 2024-02-26 3281/week @ 2024-03-04 2886/week @ 2024-03-11 3704/week @ 2024-03-18 2387/week @ 2024-03-25 3354/week @ 2024-04-01 3942/week @ 2024-04-08 4585/week @ 2024-04-15 2954/week @ 2024-04-22 2403/week @ 2024-04-29

14,137 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