Skip to content

refactor: share waiter lifecycles and simplify value ownership - #431

Merged
tisonkun merged 5 commits into
apache:mainfrom
tisonkun:codex/share-waiter-lifecycles
Nov 18, 2026
Merged

tisonkun merged 5 commits into
apache:mainfrom
tisonkun:codex/share-waiter-lifecycles

Conversation

@tisonkun

Copy link
Copy Markdown
Member

Summary

  • Give latch and once a shared countdown wait future, and share registration for MPMC and SPMC operations that wake to retry.
  • Drain removed pool objects directly into the result and consume a value cell through its existing take operation.
  • Publish completion and abandonment through the same locked transition before waking observers.

Keep the waiter token and its cancellation cleanup alongside the countdown state. Both primitives use the same lock-free completion check and locked registration path.
MPMC receivers and SPMC operations rejoin the queue after a notification if the resource is gone. Keep registration and notification together while MPMC capacity grants retain their own ownership rules.
Collect the compacted suffix directly into the returned vector after all predicates have completed, avoiding a temporary deque under the pool lock.
Taking the value clears the publication flag before moving it out, so the normal destructor already handles a consumed cell.
Completion and abandonment both detach observers before exposing the result to lock-free readers. Return the waiter set so callbacks run after unlocking.
@tisonkun
tisonkun merged commit 9d241a0 into apache:main Nov 18, 2026
9 checks passed
@tisonkun
tisonkun deleted the codex/share-waiter-lifecycles branch November 18, 2026 13:20
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