@@ -73,11 +73,10 @@ public interface IAutoCache : IAutoObject<AutoCache.Binding>
7373
7474/// <inheritdoc cref="IAutoCache"/>
7575public sealed class AutoCache : IAutoCache ,
76- IPerform < AutoCache . PopOp > ,
76+ IPerformAnyOperation ,
7777 IPerform < AutoCache . ClearOp >
7878{
7979 // Atomic operations
80- private readonly record struct PopOp ;
8180 private readonly record struct ClearOp ;
8281
8382 // Broadcasts
@@ -165,8 +164,6 @@ public Binding OnClear(Action callback)
165164 }
166165
167166 private readonly SyncSubject _subject ;
168- private readonly Passthrough _passthrough ;
169- private readonly BoxlessQueue _boxlessQueue ;
170167 private readonly Dictionary < Type , object > _comparerDict ;
171168 private readonly Dictionary < Type , CachedValue > _valueDict ;
172169 private readonly Dictionary < Type , object > _refDict ;
@@ -183,8 +180,6 @@ public Binding OnClear(Action callback)
183180 public AutoCache ( )
184181 {
185182 _subject = new SyncSubject ( this ) ;
186- _passthrough = new Passthrough ( this ) ;
187- _boxlessQueue = new BoxlessQueue ( ) ;
188183 _comparerDict = [ ] ;
189184 _valueDict = [ ] ;
190185 _refDict = [ ] ;
@@ -284,8 +279,7 @@ public void Update<T>(in T value) where T : struct
284279 _cacheCount ++ ;
285280 }
286281
287- _boxlessQueue . Enqueue ( value ) ;
288- _subject . Perform ( new PopOp ( ) ) ;
282+ _subject . Perform ( value ) ;
289283 }
290284
291285 /// <summary>
@@ -320,15 +314,16 @@ public void Update<T>(T value) where T : class
320314 }
321315
322316 _refDict [ typeof ( T ) ] = value ;
323- _boxlessQueue . Enqueue ( new RefValue ( value ) ) ;
324- _subject . Perform ( new PopOp ( ) ) ;
317+ _subject . Perform ( new RefValue ( value ) ) ;
325318 }
326319
327- private void Handle < T > ( in T value ) where T : struct =>
328- _subject . Broadcast ( value ) ; // invoke callbacks registered for this value
329-
330- void IPerform < PopOp > . Perform ( in PopOp op ) =>
331- _boxlessQueue . Dequeue ( _passthrough ) ;
320+ void IPerformAnyOperation . Perform < TOp > ( in TOp op ) where TOp : struct
321+ {
322+ if ( op is not ClearOp )
323+ {
324+ _subject . Broadcast ( op ) ;
325+ }
326+ }
332327
333328 void IPerform < ClearOp > . Perform ( in ClearOp op )
334329 {
@@ -356,17 +351,4 @@ void IPerform<ClearOp>.Perform(in ClearOp op)
356351 /// Clears the cache of any stored values.
357352 /// </summary>
358353 public void Clear ( ) => _subject . Perform ( new ClearOp ( ) ) ;
359-
360- private readonly struct Passthrough : IBoxlessValueHandler
361- {
362- public readonly AutoCache Cache { get ; }
363-
364- public Passthrough ( AutoCache cache )
365- {
366- Cache = cache ;
367- }
368-
369- public void HandleValue < TValue > ( in TValue value ) where TValue : struct =>
370- Cache . Handle ( value ) ;
371- }
372354}
0 commit comments