Document closeAdmission-before-cancel nursery stop ordering.

Explain the admit-after-cancel race and that daemons should disconnect at
the protocol layer before sealing admission (or handle closed-admission on enqueue).

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
2026-07-13 19:02:52 -04:00
co-authored by Cursor
parent 88d6367491
commit 3156652257
2 changed files with 36 additions and 7 deletions
+6 -4
View File
@@ -202,17 +202,19 @@ nursery.launch(
nvc.checkAndRethrowException();
});
nursery.requestCancelOnAll();
nursery.closeAdmission();
nursery.requestCancelOnAll();
nursery.syncAwaitAllSettlements(
sscl::ComponentThread::getSelf()->getIoContext());
```
Each slot owns a `SyncCancelerForAsyncWork`. `requestCancelOnAll()` only signals
cooperative stop; it does not destroy invokers. Invokers are retired when their
completion callbacks run. Call `closeAdmission()` explicitly before
`asyncAwaitAllSettlements()` or `syncAwaitAllSettlements()`; those APIs wait until
all slots have retired naturally and throw if admission is still open.
completion callbacks run. Call `closeAdmission()` before `requestCancelOnAll()`
so no new work can be admitted after cancel begins, and call `closeAdmission()`
explicitly before `asyncAwaitAllSettlements()` or `syncAwaitAllSettlements()`;
those APIs wait until all slots have retired naturally and throw if admission is
still open.
`syncAwaitAllSettlements()` runs a nested `io_context` loop on the **calling
thread** (it blocks in `run_one()` until every slot has retired). Pass the