ClaimableResource
Introduction
infra::ClaimableResource queues claimers until the resource can be granted.
This is useful for serialized access, but it introduces ordering and lifetime subtleties.
For broader dispatcher usage and lifetime patterns, see Event Dispatcher.
Common pitfalls
-
Do not assume a fixed timing model for
Claim(). A claim can be granted very soon (next dispatcher turn) or later, depending on current ownership and queue state. -
Do not assume there are no scheduled claim-related callbacks after releasing interest.
-
Do not destroy objects while it is still possible that claim handling is queued.
Recommended solutions
-
Design claim callbacks so they are safe regardless of whether execution is effectively immediate or delayed.
-
Explicitly release claimers during shutdown.
-
If it is not certain that no claim-related work is scheduled anymore, implement an asynchronous stop phase with
services::Stoppableand wait for stop completion before destruction.