mirror of
https://github.com/latentPrion/libspinscale.git
synced 2026-06-23 19:48:32 +00:00
Nursery: Don't pass exceptions to main loop
This commit is contained in:
@@ -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.
|
||||
|
||||
|
||||
Reference in New Issue
Block a user