Skip to content

feat: add Completion inspection and MutexGuard accessors and clarify future contracts - #449

Merged
tisonkun merged 3 commits into
mainfrom
feat/wave1-ergonomics-parity
Nov 22, 2026
Merged

tisonkun merged 3 commits into
mainfrom
feat/wave1-ergonomics-parity

Conversation

@tisonkun

@tisonkun tisonkun commented Nov 22, 2026 •

Copy link
Copy Markdown
Member

Summary

Close out the remaining Wave 1 post-completion future contract documentation and non-blocking inspection ergonomics across three focused commits:

  1. Clarify post-completion polling contracts for hand-written futures (Review what hand-written futures do when polled after completion #408): Document that waitgroup::Wait and shutdown::Shutdown idempotently return Poll::Ready(()) when polled again after completion, while oneshot::Recv is not fused and must not be polled again after returning Poll::Ready (leaving oneshot's runtime state machine untouched).
  2. Add non-blocking Completion inspection: Expose lock-free Completion::get (Option<Result<&T, Abandoned>>) and Completer::is_disconnected so callers can inspect settled completion outcomes or check whether all observers have been dropped without waiting.
  3. Expose MutexGuard::mutex and OwnedMutexGuard::mutex: Provide associated mutex accessors returning &'a Mutex<T> and &Arc<Mutex<T>> without shadowing methods on T via Deref, replacing the condvar-only internal helpers and enabling callers to retain a lock reference before moving a guard into a cancellable operation.

Fixes #408
Part of #445

@tisonkun
tisonkun force-pushed the feat/wave1-ergonomics-parity branch from 9800636 to f10ee97 Compare November 22, 2026 02:52
@tisonkun tisonkun changed the title feat: enforce hand-written future contracts and add polling and inspection APIs feat: enforce hand-written future contracts and add Completion and MutexGuard accessors Nov 22, 2026
Document that `waitgroup::Wait` and `shutdown::Shutdown` idempotently return `Poll::Ready(())` if polled again after completion, while `oneshot::Recv` is not fused and must not be polled again after returning `Poll::Ready`.

Fixes #408
Add lock-free `Completion::get` (`Option<Result<&T, Abandoned>>`) and `Completer::is_disconnected` so callers can inspect settled completion outcomes or check whether all observers have been dropped without waiting.
Expose associated `mutex` accessors on `MutexGuard` and `OwnedMutexGuard` so callers can copy out `&'a Mutex<T>` or clone `&Arc<Mutex<T>>` before moving a guard into a cancellable operation without shadowing methods on `T` via `Deref`.

Replace the `condvar`-only internal `guard_lock` and `owned_guard_lock` helpers with these public accessors.
@tisonkun
tisonkun force-pushed the feat/wave1-ergonomics-parity branch from f10ee97 to ebe2d0f Compare November 22, 2026 03:43
@tisonkun tisonkun changed the title feat: enforce hand-written future contracts and add Completion and MutexGuard accessors feat: add Completion inspection and MutexGuard accessors and clarify future contracts Nov 22, 2026
@tisonkun
tisonkun enabled auto-merge (squash) November 22, 2026 03:46
@tisonkun
tisonkun merged commit fdab996 into main Nov 22, 2026
9 checks passed
@tisonkun
tisonkun deleted the feat/wave1-ergonomics-parity branch November 22, 2026 03:46
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.

Review what hand-written futures do when polled after completion

1 participant