pub trait WarmingCreditSink: Send + Sync {
// Required method
fn credit(&self, hash: Hash, units: u64);
}Expand description
Non-blocking enqueue boundary for warming serve credits on the serve path.
A stream task calls Self::credit as its last act on a clean completion,
so the implementation MUST NOT take the bucket lock. Every ledger operation
is O(1), so the hazard is not a long hold — it is that a serve completion
which waits for the lock at all keeps the stream’s lane slot and floor
reservation alive for the length of the wait. The buy loop holds that lock
on the cache-miss path and the aggregator holds it to apply credits, so a
serve that took the lock and arrived in either window would pay for it. That
is the cost this contract exists to refuse. The runtime uses the channel sink from
spawn_warming_creditor; tests use the test-support
DirectWarmingCreditSink.
An implementation that defers the credit MUST resolve the hash’s source
before it hands the credit off, and carry the source rather than the hash.
Resolving at apply time instead would let an eviction (WarmingAllowance::forget)
and a re-warm from a different source land in between, and the credit would
follow the new tag — paying one source for another’s serve.
Required Methods§
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".