Skip to content

Commit 23778c2

Browse files
authored
Cache LFU drain buffers delegate (#461)
1 parent 0588062 commit 23778c2

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

BitFaster.Caching/Lfu/ConcurrentLfu.cs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,7 @@ public sealed class ConcurrentLfu<K, V> : ICache<K, V>, IAsyncCache<K, V>, IBoun
7070
private readonly object maintenanceLock = new();
7171

7272
private readonly IScheduler scheduler;
73+
private readonly Action drainBuffers;
7374

7475
private readonly LfuNode<K, V>[] drainBuffer;
7576

@@ -110,6 +111,7 @@ public ConcurrentLfu(int concurrencyLevel, int capacity, IScheduler scheduler, I
110111
this.capacity = new LfuCapacityPartition(capacity);
111112

112113
this.scheduler = scheduler;
114+
this.drainBuffers = () => this.DrainBuffers();
113115

114116
this.drainBuffer = new LfuNode<K, V>[this.readBuffer.Capacity];
115117
}
@@ -532,7 +534,7 @@ private void TryScheduleDrain()
532534
}
533535

534536
this.drainStatus.VolatileWrite(DrainStatus.ProcessingToIdle);
535-
scheduler.Run(() => this.DrainBuffers());
537+
scheduler.Run(this.drainBuffers);
536538
}
537539
}
538540
finally

0 commit comments

Comments
 (0)