AptLarder::SingleFlight
Deduplicates concurrent fetches for the same cache key.
The first fiber to call run for a given key becomes the leader and
executes the block. Every subsequent fiber that calls run for the same
key while the leader is still running becomes a waiter and blocks on a
channel until the leader finishes.
When the leader's block returns (or raises), the channel is closed, waking all waiters at once (broadcast semantics — a send would only wake one). The exception, if any, propagates only in the leader fiber; waiters return normally regardless of whether the leader succeeded or failed.
The same key can be reused immediately after a run completes.
Constructors
new
Source