feat(event): add a manual-reset event - #243
Merged
Merged
Conversation
# Conflicts: # CHANGELOG.md # README.md # asyncband/src/internal/mod.rs # asyncband/src/lib.rs # tests-integration/tests/traits_test.rs
tisonkun
approved these changes
Aug 30, 2026
tisonkun
left a comment
Member
There was a problem hiding this comment.
I have an idea that can improve the internal representation. Will create an issue for exploring (I may be wrong).
Push commits to refine APIs and docs. The docs update may be less-than-awesome so feel free to follow-up improve them.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
asyncband::event::ManualResetEvent, a reusable level-triggered signal with explicit initial state, state inspection,set, andresetwaitandArc-owningwait_ownedmethods while keeping their implementation future types privateDesign Notes
The event keeps its boolean state and waiter list under one mutex. An unset-to-set transition marks and detaches the complete registered cohort before invoking any waker, so a later reset cannot undo those waits and a reentrant wake callback cannot join the transition already in progress.
WaitListretains that per-wait commitment; alternative waiter storage can be explored independently without changing the public API.Wakers are cloned, invoked, and dropped outside the state lock. Registration rechecks the complete state after cloning a waker because clone callbacks may re-enter the event. If one wake callback panics, the remaining callbacks are still attempted before the first panic resumes.
Waits register on their first poll, not when their futures are constructed. Consequently,
set(); reset();is not a pulse for an unpolled future. An unset-to-set transition publishes preceding writes to waits it releases and to waits first polled while the event remains set;is_setremains only a snapshot.Validation
cargo x checkcargo x testcargo x lintCloses #221.