crossbeam-queue
1.0.3
See the version list below for details.
dotnet add package crossbeam-queue --version 1.0.3
NuGet\Install-Package crossbeam-queue -Version 1.0.3
<PackageReference Include="crossbeam-queue" Version="1.0.3" />
<PackageVersion Include="crossbeam-queue" Version="1.0.3" />
<PackageReference Include="crossbeam-queue" />
paket add crossbeam-queue --version 1.0.3
#r "nuget: crossbeam-queue, 1.0.3"
#:package crossbeam-queue@1.0.3
#addin nuget:?package=crossbeam-queue&version=1.0.3
#tool nuget:?package=crossbeam-queue&version=1.0.3
crossbeam-queue
Concurrent multi-producer, multi-consumer queues for C#.
Choose a queue
| Type | Storage | Behavior |
|---|---|---|
ArrayQueue<T> |
Fixed-capacity array | TryEnqueue returns false when full. Enqueue replaces the oldest element when full and reports the replaced value. |
SegQueue<T> |
Linked, fixed-size blocks | Grows as needed. Its constructor capacity limits how many unused blocks are retained for reuse, not how many elements can be queued. |
Both constructors require a positive capacity.
ArrayQueue<T>
Use ArrayQueue<T> when the number of queued elements must stay within a fixed bound.
TryEnqueue leaves a full queue unchanged and returns false. Enqueue always adds the new
element; when full, it removes the oldest element and returns it in an EnqueueResult.
using System;
using crossbeam;
var queue = new ArrayQueue<string>(capacity: 2);
queue.TryEnqueue("first");
queue.TryEnqueue("second");
ArrayQueue<string>.EnqueueResult result = queue.Enqueue("third");
if (result.TryGetOverwritten(out var overwritten))
Console.WriteLine($"Replaced: {overwritten}");
while (queue.TryDequeue(out var item))
Console.WriteLine(item);
Use EnqueueResult.TryGetOverwritten to determine whether an element was replaced and retrieve it.
The replaced value may itself be null or the default value of T.
SegQueue<T>
Use SegQueue<T> when there is no fixed element capacity. It allocates additional blocks as
needed. Its constructor argument sets the maximum number of unused blocks kept for reuse; blocks
beyond that limit are not retained in the reuse pool.
using System;
using crossbeam;
var queue = new SegQueue<string>(capacity: 4);
queue.Enqueue("first");
queue.Enqueue("second");
while (queue.TryDequeue(out var item))
Console.WriteLine(item);
Concurrent use
Both queue types support concurrent producers and consumers. Both expose Count and IsEmpty;
ArrayQueue<T> also exposes Capacity and IsFull. These properties report the state observed
when read, and another operation may change the queue immediately afterward. Do not use them to
reserve capacity or coordinate queue operations; use the result of TryEnqueue or TryDequeue
instead.
The queues accept null values. For TryDequeue, use the returned bool to distinguish an empty
queue from a dequeued null value.
Rust implementations
License
Distributed under the MIT License.
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net5.0 is compatible. net5.0-windows was computed. net6.0 is compatible. net6.0-android was computed. net6.0-ios was computed. net6.0-maccatalyst was computed. net6.0-macos was computed. net6.0-tvos was computed. net6.0-windows was computed. net7.0 is compatible. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. net8.0 is compatible. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. net9.0 is compatible. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. net10.0 is compatible. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
| .NET Core | netcoreapp3.0 was computed. netcoreapp3.1 was computed. |
| .NET Standard | netstandard2.1 is compatible. |
| MonoAndroid | monoandroid was computed. |
| MonoMac | monomac was computed. |
| MonoTouch | monotouch was computed. |
| Tizen | tizen60 was computed. |
| Xamarin.iOS | xamarinios was computed. |
| Xamarin.Mac | xamarinmac was computed. |
| Xamarin.TVOS | xamarintvos was computed. |
| Xamarin.WatchOS | xamarinwatchos was computed. |
-
.NETStandard 2.1
- System.Runtime.CompilerServices.Unsafe (>= 6.0.0)
-
net10.0
- No dependencies.
-
net5.0
- No dependencies.
-
net6.0
- No dependencies.
-
net7.0
- No dependencies.
-
net8.0
- No dependencies.
-
net9.0
- No dependencies.
NuGet packages (1)
Showing the top 1 NuGet packages that depend on crossbeam-queue:
| Package | Downloads |
|---|---|
|
ErinnTask
Lightweight asynchronous primitives. |
GitHub repositories
This package is not used by any popular GitHub repositories.