Nursery: Don't pass exceptions to main loop

This commit is contained in:
2026-06-09 10:43:20 -04:00
parent 565e339a8b
commit 5689ac3914
2 changed files with 17 additions and 27 deletions
+5 -7
View File
@@ -190,11 +190,10 @@ nursery.openAdmission();
auto lease = nursery.getNewSlotLease();
lease.getSyncCanceler().startAcceptingWork();
std::exception_ptr &exceptionStorage = lease.getExceptionStorage();
lease.setOnSettledHook(
[&exceptionStorage]()
[](std::exception_ptr &exceptionPtr)
{
sscl::co::NonViralCompletion nvc(exceptionStorage);
sscl::co::NonViralCompletion nvc(exceptionPtr);
nvc.checkAndRethrowException();
});
lease.fillSlot(
@@ -221,10 +220,9 @@ all slots have retired naturally and throw if admission is still open.
`Slot::Lease` is commit-required: an uncommitted lease removes its reservation on
destruction. `fillSlot()` takes an invoker factory (deferred construction) because
non-viral coroutines may complete synchronously during invoker construction.
The factory may capture `lease` by reference; `setOnSettledHook()` may not.
The hook runs after the lease is destroyed, so capture slot-owned state such as
`lease.getExceptionStorage()` (a reference to the slot's `exceptionPtr`), not
`lease` itself.
The factory may capture `lease` by reference; `setOnSettledHook()` may not
capture `lease` itself. The nursery passes the slot's `exceptionPtr` into the
hook at retirement.
`Slot::Handle` is an opaque slot pointer valid only while the slot remains in the
nursery.