Skip to content

1.0.0 - #6

Merged
al8n merged 12 commits into
mainfrom
1.0.0
Apr 14, 2026
Merged

al8n merged 12 commits into
mainfrom
1.0.0

Conversation

@al8n

@al8n al8n commented Apr 14, 2026

Copy link
Copy Markdown
Owner

No description provided.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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::WaitGroup and re-exports it as wg::WaitGroup in no_std builds.
  • Renames APIs (waitings() → remaining(), AsyncWaitGroup → future::WaitGroup) and adds AddAssign (+=) 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 like dep:triomphe / triomphe?/default, and format-string identifier capture like {prev} / {num} in debug_assert!). Either bump rust-version to 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.

Comment thread src/lib.rs
#![doc = include_str!("../README.md")]
#![cfg_attr(not(all(feature = "std", test)), no_std)]
#![deny(missing_docs, warnings)]
#![forbid(unsafe_code)]

Copilot AI Apr 14, 2026

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

#![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).

Suggested change
#![forbid(unsafe_code)]
#![cfg_attr(not(feature = "future"), forbid(unsafe_code))]

Copilot uses AI. Check for mistakes.
Comment thread src/lib.rs Outdated
Comment on lines +52 to +56
/// 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;

Copilot AI Apr 14, 2026

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copilot uses AI. Check for mistakes.
Comment thread src/spin.rs Outdated
//! overhead.
//!
//! Prefer [`WaitGroup`](crate::WaitGroup) for longer waits under `std`.
//! Prefer [`AsyncWaitGroup`](crate::AsyncWaitGroup) for async contexts.

Copilot AI Apr 14, 2026

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Suggested change
//! Prefer [`AsyncWaitGroup`](crate::AsyncWaitGroup) for async contexts.
//! Prefer [`WaitGroup`](crate::future::WaitGroup) for async contexts.

Copilot uses AI. Check for mistakes.
@codecov

codecov Bot commented Apr 14, 2026 •

Copy link
Copy Markdown

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 ☂️

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Comment thread Cargo.toml Resolved
Comment thread src/spin.rs Resolved
Comment thread .github/workflows/ci.yml
- name: cargo build --target ${{ matrix.target }}
run: |
rustup target add ${{ matrix.target }}
cargo build --target ${{ matrix.target }}

Copilot AI Apr 14, 2026

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Suggested change
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

Copilot uses AI. Check for mistakes.
Comment thread .github/workflows/loc.yml
Comment on lines +39 to +49

- 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');

Copilot AI Apr 14, 2026

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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).

Suggested change
- 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');

Copilot uses AI. Check for mistakes.
Comment thread src/lib.rs Resolved
Comment thread src/lib.rs Resolved
Comment thread src/spin.rs Resolved
Comment thread README.md Resolved
al8n and others added 2 commits April 14, 2026 17:12
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Comment thread tests/future.rs
Comment on lines +174 to +175
let wg = WaitGroup::new();
for _ in 0..100000 {

Copilot AI Apr 14, 2026

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Suggested change
let wg = WaitGroup::new();
for _ in 0..100000 {
const TASKS: usize = 1_000;
let wg = WaitGroup::new();
for _ in 0..TASKS {

Copilot uses AI. Check for mistakes.
Comment thread tests/future.rs Resolved
Comment thread src/lib.rs
Comment on lines 20 to +23
#![doc = include_str!("../README.md")]
#![cfg_attr(not(all(feature = "std", test)), no_std)]
#![deny(missing_docs, warnings)]
#![forbid(unsafe_code)]

Copilot AI Apr 14, 2026

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copilot uses AI. Check for mistakes.
Comment thread Cargo.toml Resolved
Comment thread Cargo.toml Resolved
Comment thread .github/workflows/ci.yml Resolved
Comment thread tests/future.rs
Comment on lines +6 to +8
#[cfg(all(feature = "alloc", not(feature = "std")))]
extern crate alloc as std;

Copilot AI Apr 14, 2026

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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::....

Suggested change
#[cfg(all(feature = "alloc", not(feature = "std")))]
extern crate alloc as std;

Copilot uses AI. Check for mistakes.
Comment thread .github/workflows/ci.yml Resolved
Comment thread .github/workflows/ci.yml Resolved

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

  • future can be enabled without also enabling std or alloc (e.g. default-features = false, features = ["future"]). In that case the future module is cfg’d out in src/lib.rs, leaving users with no exported WaitGroup. Consider making future depend on alloc (and/or adding a compile_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.

Comment thread tests/spin.rs
Comment on lines +8 to +10
#[cfg(all(feature = "alloc", not(feature = "std")))]
extern crate alloc as std;

Copilot AI Apr 14, 2026

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Suggested change
#[cfg(all(feature = "alloc", not(feature = "std")))]
extern crate alloc as std;

Copilot uses AI. Check for mistakes.
Comment thread tests/future.rs Resolved
Comment thread README.md
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]

Copilot AI Apr 14, 2026

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The proper brand capitalization is “GitHub”. Consider updating the badge alt text (and any visible label text) from "github" to "GitHub" for consistency.

Suggested change
[<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]

Copilot uses AI. Check for mistakes.
Comment thread .github/workflows/loc.yml
Comment on lines +14 to +21
pull_request:
paths-ignore:
- 'README.md'
- 'COPYRIGHT'
- 'LICENSE*'
- '**.md'
- '**.txt'
- 'art'

Copilot AI Apr 14, 2026

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copilot uses AI. Check for mistakes.
Comment thread .github/workflows/loc.yml
Comment on lines +43 to +47
- name: Upload total loc to GitHub Gist
uses: actions/github-script@v9
with:
github-token: ${{ secrets.GIST_PAT }}
script: |

Copilot AI Apr 14, 2026

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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).

Copilot uses AI. Check for mistakes.
Comment thread src/lib.rs
Comment on lines 20 to +33
#![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.

Copilot AI Apr 14, 2026

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copilot uses AI. Check for mistakes.
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
@al8n
al8n merged commit de0e9a8 into main Apr 14, 2026
27 checks passed
@al8n
al8n deleted the 1.0.0 branch April 14, 2026 09:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants