Crates.io | sync-wait-group |
lib.rs | sync-wait-group |
version | 0.1.1 |
source | src |
created_at | 2022-04-27 11:59:41.516191 |
updated_at | 2022-07-07 08:21:26.082876 |
description | Wait group for synchronizing the beginning or end of some computation. |
homepage | https://github.com/davidli2010/sync-wait-group |
repository | https://github.com/davidli2010/sync-wait-group.git |
max_upload_size | |
id | 576009 |
size | 19,250 |
Wait group for synchronizing the beginning or end of some computation.
This crate is duplicated WaitGroup
from crossbeam_utils::sync::WaitGroup
,
but use parking_lot::{Mutex, Condvar}
instead of std::sync::{Mutex, Condvar}
.
use sync_wait_group::WaitGroup;
use std::thread;
// Create a new wait group.
let wg = WaitGroup::new();
for _ in 0..4 {
// Create another reference to the wait group.
let wg = wg.clone();
thread::spawn(move || {
// Do some work.
// Drop the reference to the wait group.
drop(wg);
});
}
// Block until all threads have finished their work.
wg.wait();
This version of sync-wait-group
requires Rust 1.56 or later.
Dual-licensed to be compatible with the Rust project.
Licensed under the Apache License, Version 2.0 http://www.apache.org/licenses/LICENSE-2.0 or the MIT license http://opensource.org/licenses/MIT, at your option. This file may not be copied, modified, or distributed except according to those terms.
Unless you explicitly state otherwise, any contribution intentionally submitted
for inclusion in sync-wait-group
by you, shall be licensed as Apache-2.0 and MIT, without any additional
terms or conditions.