diff --git a/BitFaster.Caching/Buffers/MpscBoundedBuffer.cs b/BitFaster.Caching/Buffers/MpscBoundedBuffer.cs index a5e55880..8879b834 100644 --- a/BitFaster.Caching/Buffers/MpscBoundedBuffer.cs +++ b/BitFaster.Caching/Buffers/MpscBoundedBuffer.cs @@ -254,6 +254,9 @@ private static int Length(Span output) /// /// Removes all values from the buffer. /// + /// + /// Clear must be called from the single consumer thread. + /// public void Clear() { while (TryTake(out _) != BufferStatus.Empty) diff --git a/BitFaster.Caching/Buffers/StripedMpscBuffer.cs b/BitFaster.Caching/Buffers/StripedMpscBuffer.cs index f5667fb9..8911b98f 100644 --- a/BitFaster.Caching/Buffers/StripedMpscBuffer.cs +++ b/BitFaster.Caching/Buffers/StripedMpscBuffer.cs @@ -123,7 +123,7 @@ public BufferStatus TryAdd(T item) /// Removes all values from the buffer. /// /// - /// Not thread safe. + /// Clear must be called from the single consumer thread. /// public void Clear() { diff --git a/BitFaster.Caching/Lfu/ConcurrentLfuCore.cs b/BitFaster.Caching/Lfu/ConcurrentLfuCore.cs index 4afd172e..bc0d7c77 100644 --- a/BitFaster.Caching/Lfu/ConcurrentLfuCore.cs +++ b/BitFaster.Caching/Lfu/ConcurrentLfuCore.cs @@ -137,11 +137,10 @@ public void Clear() { this.Trim(this.Count); - this.readBuffer.Clear(); - this.writeBuffer.Clear(); - lock (maintenanceLock) { + this.readBuffer.Clear(); + this.writeBuffer.Clear(); this.cmSketch.Clear(); } }