Skip to content

refactor: clarify waiter arena contracts - #191

Merged
tisonkun merged 5 commits into
mainfrom
codex/refine-waiter-arena
Aug 26, 2026
Merged

refactor: clarify waiter arena contracts#191
tisonkun merged 5 commits into
mainfrom
codex/refine-waiter-arena

Conversation

@tisonkun

@tisonkun tisonkun commented Aug 26, 2026

Copy link
Copy Markdown
Member

Summary

  • represent reusable arena slots with SlotId, removing manual encode/decode calls and the associated unsafe construction
  • represent a caller-owned WaitSet entry with the non-Copy WakerToken, and use slot/token consistently through its callers
  • document the arena free-list, slot-ID lifetime, and wake-epoch invariants while preserving next_vacant as the field name
  • make the arena module and inline-one value holder private, with the sibling-facing arena API declared pub inside that module boundary
  • hide ArenaValues behind owning iterators from Arena::take_all and WaitSet::take_wakers
  • retain option-niche size checks without imposing unnecessary repr(transparent) layout guarantees on internal wrappers
  • cover repeated unlinking of detached waiters, middle-waiter removal with slot reuse, and stale Waker tokens across wake epochs

The existing module-level allow(dead_code) remains intentionally simple: WaitList and WaitSet use different subsets of the arena API, so single-primitive feature builds inevitably leave part of it unused.

Small-vector decision

ArenaValues is the safe, specialized equivalent of the small-vector behavior needed here: keep one value inline, store only additional values in a Vec, and consume the values through iteration. I evaluated vendoring SmallVec 1.15.2, but its general implementation and unsafe storage machinery are disproportionate to these three operations. This keeps the focused representation without adding a production dependency or vendored third-party surface.

Validation

  • cargo +1.86.0 check --package asyncband --all-features --tests
  • cargo test --workspace --all-features
  • cargo run -p x -- check
  • cargo run -p x -- lint

@tisonkun
tisonkun merged commit 2f1fa5e into main Aug 26, 2026
9 checks passed
@tisonkun
tisonkun deleted the codex/refine-waiter-arena branch August 26, 2026 02:35
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.

1 participant