yastl

Crates.ioyastl
lib.rsyastl
version0.1.2
sourcesrc
created_at2021-02-23 08:13:32.214782
updated_at2021-02-25 17:57:25.325483
descriptionYet another scoped threadpool library
homepage
repositoryhttps://github.com/Stupremee/yastl
max_upload_size
id359363
size23,880
Justus K (Stupremee)

documentation

https://docs.rs/yastl

README

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.

Commit count: 13

cargo fmt