From e38925e249d39e238a8650470c21708e8aa33f86 Mon Sep 17 00:00:00 2001 From: Meta Vens Date: Fri, 23 Oct 2026 12:18:12 +0200 Subject: [PATCH] Caching: the cacheless call reaches the store's gate through WhileDetached (the base class owns the gate; 694e6fe6 did not build) Co-Authored-By: Claude Opus 5.5 --- src/GameCult.Caching/CultCache.cs | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/src/GameCult.Caching/CultCache.cs b/src/GameCult.Caching/CultCache.cs index c69a55d4..09b8e3f3 100644 --- a/src/GameCult.Caching/CultCache.cs +++ b/src/GameCult.Caching/CultCache.cs @@ -3595,7 +3595,7 @@ namespace GameCult.Caching protected void Held(Action body) => Held(() => { body(); return true; }); - // The store's cacheless gate, taken by the attach so that no cacheless call is mid-flight while the store gains a cache. + // The store's own gate. The attach holds it across its whole body, and a cacheless call holds it for its whole run (ForTheCall), so no call is mid-flight while the store gains a cache and none starts between the attach's refusal and its end. internal T WhileDetached(Func body) { lock (_detachedGate) @@ -4304,9 +4304,8 @@ namespace GameCult.Caching // the call's argument, not store state: it is attached for the call and detached when the call ends, whatever it does. A // cacheless store holds none between calls. Lock order: an attach takes the cache's gate, then the store's. This takes only the // store's, and nothing takes the store's gate and then a cache's. - private void ForTheCall(CultDocumentRegistry? registry, Action body) - { - lock (_detachedGate) + private void ForTheCall(CultDocumentRegistry? registry, Action body) => + WhileDetached(() => { RefuseWhenAttached(); UseRegistry(registry); @@ -4318,8 +4317,8 @@ namespace GameCult.Caching { UseRegistry(null); } - } - } + return true; + }); private void WriteOne(CultPersistedRecord record, CultSchemaCatalogEntry catalogEntry, bool? holdsIds) {