Repository navigation
Conversation
There was a problem hiding this comment.
Pull request overview
This PR marks the crate’s 1.0.0 release by unifying and expanding the WaitGroup API across blocking (std), async (future), and lock-free (spin) variants, along with updated tests, documentation, and CI to match the new surface.
Changes:
- Introduces
wg::spin::WaitGroupand re-exports it aswg::WaitGroupinno_stdbuilds. - Renames APIs (
waitings()→remaining(),AsyncWaitGroup→future::WaitGroup) and addsAddAssign(+=) shorthand. - Expands integration tests and CI coverage (MSRV check, sanitizers, Miri, feature-powerset builds/tests).
Reviewed changes
Copilot reviewed 19 out of 19 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| tests/sync.rs | Updates sync tests for remaining() and adds edge-case coverage (done on zero, wait-on-zero, +=). |
| tests/spin.rs | Adds dedicated tests for the new spin::WaitGroup. |
| tests/send_sync.rs | Adds compile-time Send + Sync assertions for public waitgroup types. |
| tests/future.rs | Migrates tests to wg::future::WaitGroup, updates assertions to remaining(), and adds manual-poll coverage. |
| src/sync.rs | Improves poisoning behavior, adds AddAssign, renames waitings() to remaining(), updates docs and overflow debug assertions. |
| src/spin.rs | Adds the new lock-free/spinning WaitGroup implementation and docs. |
| src/no_std.rs | Removes the old no_std waitgroup implementation in favor of spin. |
| src/lib.rs | Reorganizes module exports, adds spin module, re-exports spin::WaitGroup for no_std, and forbids unsafe code. |
| src/future.rs | Renames AsyncWaitGroup to WaitGroup, updates behavior/docs, changes poll logic, adds AddAssign, and introduces remaining(). |
| examples/future.rs | Updates example to use wg::future::WaitGroup. |
| ci/sanitizer.sh | Adds sanitizer runs (ASAN/LSAN/MSAN/TSAN) for CI. |
| ci/miri_tb.sh | Adds Miri (tree-borrows) script for multiple targets. |
| ci/miri_sb.sh | Adds Miri (stacked borrows) script for multiple targets. |
| README.md | Rewrites docs for 3-variant API, new feature flags, updated installation and examples, and adds MSRV statement. |
| Cargo.toml | Bumps version to 1.0.0, declares rust-version, adjusts features/deps, and fixes required-features for future test/example. |
| CHANGELOG.md | Adds 1.0.0 changelog with breaking changes, fixes, and migration notes. |
| .github/workflows/loc.yml | Adds a workflow to publish LoC metrics. |
| .github/workflows/ci.yml | Expands CI matrix, adds MSRV job, feature-powerset build/test, cross builds, sanitizers, and Miri; updates coverage job. |
| .github/dependabot.yml | Adds Dependabot config for Cargo and GitHub Actions. |
Comments suppressed due to low confidence (2)
src/future.rs:28
- Grammar in the public type docs: "An WaitGroup" should be "A WaitGroup". Since this is user-facing documentation, fixing the article improves readability and professionalism.
/// An WaitGroup waits for a collection of threads to finish.
///
/// The main thread calls [`add`] to set the number of
/// thread to wait for. Then each of the tasks
/// runs and calls Done when finished. At the same time,
Cargo.toml:22
- The crate declares
rust-version = "1.56.0", but the manifest and code use features that require a newer Cargo/Rust toolchain (e.g., namespaced features likedep:triomphe/triomphe?/default, and format-string identifier capture like{prev}/{num}indebug_assert!). Either bumprust-versionto the minimum that supports these (likely >= 1.60), or rewrite the manifest and formatting to be compatible with 1.56.
edition = "2021"
rust-version = "1.56.0"
[features]
default = ["std", "parking_lot", "triomphe"]
alloc = []
std = ["triomphe?/default", "event-listener?/default", "futures-core?/default"]
triomphe = ["dep:triomphe"]
parking_lot = ["dep:parking_lot"]
future = ["event-listener", "pin-project-lite"]
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| #![doc = include_str!("../README.md")] | ||
| #![cfg_attr(not(all(feature = "std", test)), no_std)] | ||
| #![deny(missing_docs, warnings)] | ||
| #![forbid(unsafe_code)] |
There was a problem hiding this comment.
#![forbid(unsafe_code)] will cause compilation to fail when the future feature is enabled because pin_project_lite::pin_project! typically expands to unsafe code in this crate. Either drop the forbid(unsafe_code) attribute, or refactor WaitGroupFuture to avoid pin-projection macros/unsafe in this crate (e.g., make the future Unpin or store projections differently).
| #![forbid(unsafe_code)] | |
| #![cfg_attr(not(feature = "future"), forbid(unsafe_code))] |
| /// In `no_std` builds, `WaitGroup` is an alias for [`WaitGroup`]. | ||
| /// In `std` builds, `WaitGroup` is the `Mutex`/`Condvar`-based variant | ||
| /// from the [`sync`] module. | ||
| #[cfg(not(feature = "std"))] | ||
| mod no_std; | ||
| #[cfg(not(feature = "std"))] | ||
| pub use no_std::*; | ||
| pub use spin::WaitGroup; |
There was a problem hiding this comment.
The docs say WaitGroup is an alias for [WaitGroup], which is self-referential and doesn’t explain the actual aliasing behavior. This should point to spin::WaitGroup (the re-export target in no_std builds), and the wording should clarify the std vs no_std mapping.
| //! overhead. | ||
| //! | ||
| //! Prefer [`WaitGroup`](crate::WaitGroup) for longer waits under `std`. | ||
| //! Prefer [`AsyncWaitGroup`](crate::AsyncWaitGroup) for async contexts. |
There was a problem hiding this comment.
This module-level doc links to crate::AsyncWaitGroup, but that type no longer exists after the rename to future::WaitGroup. Update the link and wording to reference crate::future::WaitGroup for async contexts.
| //! Prefer [`AsyncWaitGroup`](crate::AsyncWaitGroup) for async contexts. | |
| //! Prefer [`WaitGroup`](crate::future::WaitGroup) for async contexts. |
Welcome to Codecov 🎉Once you merge this PR into your default branch, you're all set! Codecov will compare coverage reports and display results in all future pull requests. Thanks for integrating Codecov - We've got you covered ☂️ |
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 19 out of 19 changed files in this pull request and generated 8 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| - name: cargo build --target ${{ matrix.target }} | ||
| run: | | ||
| rustup target add ${{ matrix.target }} | ||
| cargo build --target ${{ matrix.target }} |
There was a problem hiding this comment.
The cross job runs cargo build --target … without disabling default features. Because the crate’s default features include std, targets like wasm32-unknown-unknown (and other no-std targets in the matrix) will fail to build. Consider either (a) adjusting the matrix to only include std-capable targets, or (b) building with --no-default-features --features alloc (and optionally a separate std build) for the no-std targets.
| cargo build --target ${{ matrix.target }} | |
| if [ "${{ matrix.target }}" = "wasm32-unknown-unknown" ]; then | |
| cargo build --target ${{ matrix.target }} --no-default-features --features alloc | |
| else | |
| cargo build --target ${{ matrix.target }} | |
| fi |
|
|
||
| - name: Count total lines of code | ||
| run: | | ||
| tokeit | ||
| - name: Upload total loc to GitHub Gist | ||
| uses: actions/github-script@v9 | ||
| with: | ||
| github-token: ${{ secrets.GIST_PAT }} | ||
| script: | | ||
| const fs = require('fs'); | ||
| const output = fs.readFileSync('tokeit.json', 'utf8'); |
There was a problem hiding this comment.
The workflow assumes a tokeit binary is installable via cargo install tokeit and that it produces a tokeit.json file for the later upload step. If the crate/binary name or output filename differs, the workflow will fail at runtime. Consider validating the tool name/output file (or making the script read the actual output path produced by the LoC tool).
| - name: Count total lines of code | |
| run: | | |
| tokeit | |
| - name: Upload total loc to GitHub Gist | |
| uses: actions/github-script@v9 | |
| with: | |
| github-token: ${{ secrets.GIST_PAT }} | |
| script: | | |
| const fs = require('fs'); | |
| const output = fs.readFileSync('tokeit.json', 'utf8'); | |
| command -v tokeit >/dev/null 2>&1 || { echo "tokeit binary was not installed or is not on PATH"; exit 1; } | |
| - name: Count total lines of code | |
| run: | | |
| find . -maxdepth 1 -type f -name '*.json' -print | sort > /tmp/json-before.txt | |
| tokeit | |
| find . -maxdepth 1 -type f -name '*.json' -print | sort > /tmp/json-after.txt | |
| output_file="$(comm -13 /tmp/json-before.txt /tmp/json-after.txt | head -n 1)" | |
| if [ -z "$output_file" ]; then | |
| echo "No new JSON output file was produced by tokeit" | |
| exit 1 | |
| fi | |
| echo "LOC_OUTPUT_PATH=$output_file" >> "$GITHUB_ENV" | |
| - name: Upload total loc to GitHub Gist | |
| uses: actions/github-script@v9 | |
| with: | |
| github-token: ${{ secrets.GIST_PAT }} | |
| script: | | |
| const fs = require('fs'); | |
| const outputPath = process.env.LOC_OUTPUT_PATH; | |
| if (!outputPath || !fs.existsSync(outputPath)) { | |
| throw new Error(`LoC output file not found: ${outputPath || 'LOC_OUTPUT_PATH is not set'}`); | |
| } | |
| const output = fs.readFileSync(outputPath, 'utf8'); |
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 19 out of 19 changed files in this pull request and generated 9 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| let wg = WaitGroup::new(); | ||
| for _ in 0..100000 { |
There was a problem hiding this comment.
This test spawns 100,000 tasks. Now that tests/future.rs is enabled by required-features = ["future"], this is likely to cause long runtimes/timeouts in CI. Consider drastically reducing the iteration count and/or making this an #[ignore] stress test.
| let wg = WaitGroup::new(); | |
| for _ in 0..100000 { | |
| const TASKS: usize = 1_000; | |
| let wg = WaitGroup::new(); | |
| for _ in 0..TASKS { |
| #![doc = include_str!("../README.md")] | ||
| #![cfg_attr(not(all(feature = "std", test)), no_std)] | ||
| #![deny(missing_docs, warnings)] | ||
| #![forbid(unsafe_code)] |
There was a problem hiding this comment.
With the removal of the old compile_error!, --no-default-features builds with neither std nor alloc now compile but expose no usable API. Consider restoring a hard error for not(any(feature = "std", feature = "alloc")) so feature misconfiguration is caught early.
| #[cfg(all(feature = "alloc", not(feature = "std")))] | ||
| extern crate alloc as std; | ||
|
|
There was a problem hiding this comment.
extern crate alloc as std; shadows the real std crate in this integration test when alloc is enabled without std, which breaks the later use std::time::Duration / std::sync::atomic imports (alloc has no time/atomics). Integration tests always build with the real std, so this alias should be removed (or renamed) and the test should just use std::....
| #[cfg(all(feature = "alloc", not(feature = "std")))] | |
| extern crate alloc as std; |
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 19 out of 19 changed files in this pull request and generated 6 comments.
Comments suppressed due to low confidence (1)
Cargo.toml:33
futurecan be enabled without also enablingstdoralloc(e.g.default-features = false, features = ["future"]). In that case thefuturemodule is cfg’d out insrc/lib.rs, leaving users with no exportedWaitGroup. Consider makingfuturedepend onalloc(and/or adding acompile_error!for unsupported feature combos).
[features]
default = ["std", "parking_lot", "triomphe"]
alloc = []
std = ["triomphe?/default", "event-listener?/default"]
triomphe = ["dep:triomphe"]
parking_lot = ["dep:parking_lot"]
future = ["event-listener", "pin-project-lite"]
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| #[cfg(all(feature = "alloc", not(feature = "std")))] | ||
| extern crate alloc as std; | ||
|
|
There was a problem hiding this comment.
extern crate alloc as std; in an integration test crate shadows the real std crate that the test harness relies on, so cargo test --no-default-features --features alloc will fail to compile. The tests can just use the real std (the harness links it regardless) or import from alloc without renaming it to std.
| #[cfg(all(feature = "alloc", not(feature = "std")))] | |
| extern crate alloc as std; |
| Golang like WaitGroup implementation for sync/async Rust, support `no_std` environment. | ||
|
|
||
| [<img alt="github" src="https://img.shields.io/badge/GITHUB-al8n/wg-8da0cb?style=for-the-badge&logo=Github" height="22">][Github-url] | ||
| [<img alt="github" src="https://img.shields.io/badge/github-al8n/wg-8da0cb?style=for-the-badge&logo=Github" height="22">][Github-url] |
There was a problem hiding this comment.
The proper brand capitalization is “GitHub”. Consider updating the badge alt text (and any visible label text) from "github" to "GitHub" for consistency.
| [<img alt="github" src="https://img.shields.io/badge/github-al8n/wg-8da0cb?style=for-the-badge&logo=Github" height="22">][Github-url] | |
| [<img alt="GitHub" src="https://img.shields.io/badge/GitHub-al8n/wg-8da0cb?style=for-the-badge&logo=GitHub" height="22">][Github-url] |
| pull_request: | ||
| paths-ignore: | ||
| - 'README.md' | ||
| - 'COPYRIGHT' | ||
| - 'LICENSE*' | ||
| - '**.md' | ||
| - '**.txt' | ||
| - 'art' |
There was a problem hiding this comment.
Because this workflow runs on pull_request, the later Gist-upload step will execute for PRs as well. Since that step relies on secrets.GIST_PAT, fork PRs will fail (secrets aren’t exposed). Consider limiting the workflow (or at least the upload step) to push/workflow_dispatch, or guard it with an if: condition.
| - name: Upload total loc to GitHub Gist | ||
| uses: actions/github-script@v9 | ||
| with: | ||
| github-token: ${{ secrets.GIST_PAT }} | ||
| script: | |
There was a problem hiding this comment.
This step uses secrets.GIST_PAT to update a Gist. That secret won’t be available on fork PRs, so the job will fail unless the step is guarded (e.g., only run on push/workflow_dispatch, or add an if: that checks the event/permissions).
| #![doc = include_str!("../README.md")] | ||
| #![cfg_attr(not(all(feature = "std", test)), no_std)] | ||
| #![deny(missing_docs, warnings)] | ||
| #![forbid(unsafe_code)] | ||
| #![cfg_attr(docsrs, feature(doc_cfg))] | ||
| #![cfg_attr(docsrs, allow(unused_attributes))] | ||
|
|
||
| #[cfg(not(any(feature = "alloc", feature = "std")))] | ||
| compile_error!("This crate can only be used when feature `alloc` or `std` is enabled"); | ||
|
|
||
| #[cfg(not(feature = "std"))] | ||
| extern crate alloc; | ||
| #[cfg(all(not(feature = "std"), feature = "alloc"))] | ||
| extern crate alloc as std; | ||
|
|
||
| #[cfg(feature = "std")] | ||
| extern crate std; | ||
|
|
||
| #[cfg(feature = "future")] | ||
| mod future; | ||
|
|
||
| #[cfg(feature = "future")] | ||
| #[cfg_attr(docsrs, doc(cfg(feature = "future")))] | ||
| pub use future::*; | ||
| /// A WaitGroup that can be used in async contexts. See [`future::WaitGroup`] for details. |
There was a problem hiding this comment.
The crate no longer errors out when built without either std or alloc. In that feature combination, no WaitGroup type is exported, which is confusing for users (it compiles but is unusable). Consider restoring a compile_error! for not(any(feature = "std", feature = "alloc")), and/or making future depend on alloc to prevent unsupported combos.
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
No description provided.