From 565e339a8ba869f1375fd1dd432a6bfbb80a71bf Mon Sep 17 00:00:00 2001 From: Hayodea Hekol Date: Tue, 9 Jun 2026 08:07:44 -0400 Subject: [PATCH] Nursery: Update examples to use slot and not lease in onSettled --- README.md | 11 +++++++++++ include/spinscale/co/dynamicPostingInvoker.h | 3 +++ 2 files changed, 14 insertions(+) diff --git a/README.md b/README.md index 1eed605..31e46a3 100644 --- a/README.md +++ b/README.md @@ -190,6 +190,13 @@ nursery.openAdmission(); auto lease = nursery.getNewSlotLease(); lease.getSyncCanceler().startAcceptingWork(); +std::exception_ptr &exceptionStorage = lease.getExceptionStorage(); +lease.setOnSettledHook( + [&exceptionStorage]() + { + sscl::co::NonViralCompletion nvc(exceptionStorage); + nvc.checkAndRethrowException(); + }); lease.fillSlot( [&lease]() { @@ -214,6 +221,10 @@ 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. `Slot::Handle` is an opaque slot pointer valid only while the slot remains in the nursery. diff --git a/include/spinscale/co/dynamicPostingInvoker.h b/include/spinscale/co/dynamicPostingInvoker.h index d663c04..4565344 100644 --- a/include/spinscale/co/dynamicPostingInvoker.h +++ b/include/spinscale/co/dynamicPostingInvoker.h @@ -31,6 +31,9 @@ template using DynamicViralPostingInvoker = ViralPostingInvoker; +using DynamicNonViralPostingInvoker = + NonViralPostingInvoker; + } // namespace sscl::co #endif // DYNAMIC_POSTING_INVOKER_H