https://github.com/just-do-halee/wag
Go like sync.WaitGroup implementation in Rust. (sync/async)
https://github.com/just-do-halee/wag
async rust rust-library sync waitgroup
Last synced: about 1 year ago
JSON representation
Go like sync.WaitGroup implementation in Rust. (sync/async)
- Host: GitHub
- URL: https://github.com/just-do-halee/wag
- Owner: just-do-halee
- License: apache-2.0
- Created: 2022-12-04T18:55:27.000Z (over 3 years ago)
- Default Branch: main
- Last Pushed: 2022-12-06T06:00:25.000Z (over 3 years ago)
- Last Synced: 2025-06-04T17:21:17.245Z (about 1 year ago)
- Topics: async, rust, rust-library, sync, waitgroup
- Language: Rust
- Homepage:
- Size: 11.7 KB
- Stars: 2
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- Funding: .github/FUNDING.yml
- License: LICENSE-APACHE
Awesome Lists containing this project
README
# **`WAG`**
Go like sync.WaitGroup implementation in Rust. (sync/async)
[![CI][ci-badge]][ci-url]
[![Crates.io][crates-badge]][crates-url]
[![Licensed][license-badge]][license-url]
[![Twitter][twitter-badge]][twitter-url]
[ci-badge]: https://github.com/just-do-halee/wag/actions/workflows/ci.yml/badge.svg
[crates-badge]: https://img.shields.io/crates/v/wag.svg?labelColor=383636
[license-badge]: https://img.shields.io/crates/l/wag?labelColor=383636
[twitter-badge]: https://img.shields.io/twitter/follow/do_halee?style=flat&logo=twitter&color=4a4646&labelColor=333131&label=just-do-halee
[ci-url]: https://github.com/just-do-halee/wag/actions
[twitter-url]: https://twitter.com/do_halee
[crates-url]: https://crates.io/crates/wag
[license-url]: https://github.com/just-do-halee/wag
| [Examples](./tests/) | [Docs](https://docs.rs/wag) | [Latest Note](./CHANGELOG.md) |
```toml
wag = "0.3.0"
```
## **`How to use,`**
```rust
use wag::WaitGroup;
let wg = WaitGroup::new();
```
```rust
for _ in 0..10 {
let w = wg.add();
thread::spawn(move || {
// ...
w.done();
});
});
wg.wait(); // or wg.async_wait().await;
```
```rust
for w in wg.adds::<10>() {
thread::spawn(move || {
// ...
w.done();
});
});
wg.wait(); // or wg.async_wait().await;
```
```rust
let [w1, w2, w3] = wg.adds();
thread::spawn(move || {
// ...
w1.done();
});
thread::spawn(move || {
// ...
w2.done();
});
thread::spawn(move || {
// ...
w3.done();
});
wg.wait(); // or wg.async_wait().await;
```
```rust
wg.adds_iter::<10>().enumerate().for_each(|(i, w)| {
thread::spawn(move || {
// ... with i
w.done();
});
});
wg.wait(); // or wg.async_wait().await;
```