Soenneker.Utils.ConcurrentCircularQueue
11.0.214
Prefix Reserved
dotnet add package Soenneker.Utils.ConcurrentCircularQueue --version 11.0.214
NuGet\Install-Package Soenneker.Utils.ConcurrentCircularQueue -Version 11.0.214
<PackageReference Include="Soenneker.Utils.ConcurrentCircularQueue" Version="11.0.214" />
<PackageVersion Include="Soenneker.Utils.ConcurrentCircularQueue" Version="11.0.214" />
<PackageReference Include="Soenneker.Utils.ConcurrentCircularQueue" />
paket add Soenneker.Utils.ConcurrentCircularQueue --version 11.0.214
#r "nuget: Soenneker.Utils.ConcurrentCircularQueue, 11.0.214"
#:package Soenneker.Utils.ConcurrentCircularQueue@11.0.214
#addin nuget:?package=Soenneker.Utils.ConcurrentCircularQueue&version=11.0.214
#tool nuget:?package=Soenneker.Utils.ConcurrentCircularQueue&version=11.0.214
Soenneker.Utils.ConcurrentCircularQueue
A thread-safe, fixed-capacity FIFO queue that discards the oldest item when a new item exceeds its capacity.
Installation
dotnet add package Soenneker.Utils.ConcurrentCircularQueue
Usage
var recentIds = new ConcurrentCircularQueue<int>(maxSize: 3);
await recentIds.Enqueue(10);
await recentIds.Enqueue(20);
await recentIds.Enqueue(30);
await recentIds.Enqueue(40); // 10 is discarded
(bool success, int? oldest) = await recentIds.TryDequeue(); // 20
int count = await recentIds.Count(); // 2
bool contains = await recentIds.Contains(40); // true
TryDequeue() returns immediately with success == false when the queue is empty. This is a collection, not a producer/consumer channel: it has no operation that waits for a future item.
Concurrency modes
The default mode uses ConcurrentQueue<T> and atomic counting. Operations are thread-safe, but Contains() and Count() are observations made while other callers may be changing the queue.
var queue = new ConcurrentCircularQueue<Job>(100, locking: true);
With locking: true, enqueue, dequeue, count, and contains operations are serialized through an asynchronous lock. This provides a consistent point-in-time observation relative to the other queue operations, at the cost of contention and asynchronous lock overhead.
Neither mode makes a multi-call sequence atomic. For example, another caller can change the queue between Contains() and TryDequeue().
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net11.0 is compatible. |
-
net11.0
- Soenneker.Asyncs.Locks (>= 11.0.131)
- Soenneker.Extensions.ValueTask (>= 11.0.139)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
| Version | Downloads | Last Updated |
|---|---|---|
| 11.0.214 | 98 | 12/2/2026 |
| 11.0.213 | 51 | 12/2/2026 |
| 11.0.212 | 93 | 12/2/2026 |
| 11.0.211 | 101 | 12/1/2026 |
| 11.0.210 | 93 | 12/1/2026 |
| 11.0.209 | 100 | 11/30/2026 |
| 11.0.208 | 88 | 11/30/2026 |
| 11.0.207 | 111 | 11/29/2026 |
| 11.0.206 | 95 | 11/29/2026 |
| 11.0.205 | 210 | 11/18/2026 |
| 11.0.204 | 99 | 11/18/2026 |
| 11.0.203 | 193 | 11/11/2026 |
| 11.0.202 | 90 | 11/11/2026 |
| 11.0.201 | 93 | 11/11/2026 |
| 11.0.200 | 108 | 11/11/2026 |
| 11.0.199 | 95 | 11/11/2026 |
| 11.0.198 | 280 | 11/2/2026 |
| 11.0.197 | 149 | 10/27/2026 |
| 11.0.196 | 109 | 10/26/2026 |
| 11.0.195 | 99 | 10/26/2026 |
Updated Multiple NuGet packages