VOOZH about

URL: https://www.nuget.org/packages/Soenneker.Queues.Intrusive.ValueMpsc/

⇱ NuGet Gallery | Soenneker.Queues.Intrusive.ValueMpsc 4.0.24


ο»Ώ

πŸ‘ Image
Soenneker.Queues.Intrusive.ValueMpsc 4.0.24

Prefix Reserved
dotnet add package Soenneker.Queues.Intrusive.ValueMpsc --version 4.0.24
 
 
NuGet\Install-Package Soenneker.Queues.Intrusive.ValueMpsc -Version 4.0.24
 
 
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="Soenneker.Queues.Intrusive.ValueMpsc" Version="4.0.24" />
 
 
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Soenneker.Queues.Intrusive.ValueMpsc" Version="4.0.24" />
 
Directory.Packages.props
<PackageReference Include="Soenneker.Queues.Intrusive.ValueMpsc" />
 
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add Soenneker.Queues.Intrusive.ValueMpsc --version 4.0.24
 
 
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: Soenneker.Queues.Intrusive.ValueMpsc, 4.0.24"
 
 
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package Soenneker.Queues.Intrusive.ValueMpsc@4.0.24
 
 
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=Soenneker.Queues.Intrusive.ValueMpsc&version=4.0.24
 
Install as a Cake Addin
#tool nuget:?package=Soenneker.Queues.Intrusive.ValueMpsc&version=4.0.24
 
Install as a Cake Tool
The NuGet Team does not provide support for this client. Please contact its maintainers for support.

πŸ‘ alternate text is missing from this package README image
πŸ‘ alternate text is missing from this package README image
πŸ‘ alternate text is missing from this package README image
πŸ‘ alternate text is missing from this package README image

πŸ‘ alternate text is missing from this package README image
Soenneker.Queues.Intrusive.ValueMpsc

A zero-allocation, high-performance intrusive MPSC queue using value-based state


Installation

dotnet add package Soenneker.Queues.Intrusive.ValueMpsc

Overview

ValueIntrusiveMpscQueue<TNode> is a multi-producer / single-consumer (MPSC) queue built around a classic intrusive algorithm with a permanent sentinel (β€œstub”) node.

This value variant is designed to minimize indirection and memory traffic by storing queue state directly in value fields rather than reference wrappers.

Key characteristics:

  • Multiple producers may enqueue concurrently.
  • Exactly one consumer may dequeue.
  • Each enqueue performs a single atomic operation.
  • No allocations are performed by the queue.
  • Node linkage is stored directly on the node (intrusive).
  • Queue state is held in value types for maximum locality and predictability.

This makes it especially suitable for hot paths in low-level concurrency primitives.


Why a β€œValue” MPSC?

Compared to reference-based implementations, this variant:

  • Avoids extra object indirection.
  • Reduces cache misses in contention-heavy scenarios.
  • Plays well with aggressive inlining and AOT scenarios.
  • Is easier to embed inside other value-centric primitives.

If you are building performance-critical infrastructure (locks, schedulers, wait queues), this version is usually the right default.


Usage

Define a node type

Nodes must implement IIntrusiveNode<TNode> or derive from IntrusiveNode<TNode>.

public sealed class WorkItem : IntrusiveNode<WorkItem>
{
 public int Id;
}

Each node carries its own linkage; the queue never allocates or wraps nodes.


Create a queue with a permanent sentinel

var stub = new WorkItem();
var queue = new ValueIntrusiveMpscQueue<WorkItem>(stub);

The stub node must remain alive for the entire lifetime of the queue.


Enqueue (multi-producer)

queue.Enqueue(new WorkItem { Id = 42 });

This operation is lock-free and safe to call concurrently from multiple threads.


Dequeue (single-consumer)

if (queue.TryDequeue(out var item))
{
 // process item
}

If stronger dequeue guarantees are required (for example, when a producer has advanced the tail but not yet published the link), use:

queue.TryDequeueSpin(out var item);

Correctness and constraints

This type intentionally enforces strict usage rules:

  • Exactly one consumer thread is supported.
  • A node must not be enqueued more than once at a time.
  • Nodes may be reused only after being dequeued.
  • The sentinel (stub) node must remain alive for the queue’s lifetime.
  • TryDequeue may return false while a producer is mid-enqueue β€” this is expected.

Violating these constraints will result in undefined behavior.

This is a low-level primitive, not a general-purpose collection.


When to use this

This queue is a good fit when:

  • You are building synchronization primitives (async locks, semaphores, schedulers).
  • Allocation-free behavior is mandatory.
  • You need tight control over memory ordering and visibility.
  • You can enforce a single-consumer contract.
  • You care about instruction count, cache locality, and predictable latency.

If you need a general-purpose queue with multiple consumers, prefer ConcurrentQueue<T> or System.Threading.Channels.

Product Versions Compatible and additional computed target framework versions.
.NET net10.0 net10.0 is compatible.  net10.0-android net10.0-android was computed.  net10.0-browser net10.0-browser was computed.  net10.0-ios net10.0-ios was computed.  net10.0-maccatalyst net10.0-maccatalyst was computed.  net10.0-macos net10.0-macos was computed.  net10.0-tvos net10.0-tvos was computed.  net10.0-windows net10.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages (1)

Showing the top 1 NuGet packages that depend on Soenneker.Queues.Intrusive.ValueMpsc:

Package Downloads
Soenneker.Asyncs.Locks

The fastest .NET async lock.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
4.0.24 0 6/18/2026
4.0.23 130,026 6/5/2026
4.0.22 98 6/5/2026
4.0.21 96 6/5/2026
4.0.20 267,690 4/23/2026
4.0.19 5,193 4/23/2026
4.0.18 233,996 3/13/2026
4.0.17 115 3/12/2026
4.0.16 113 3/12/2026
4.0.15 116 3/12/2026
4.0.14 122 3/12/2026
4.0.13 121 3/12/2026
4.0.12 76,749 3/11/2026
4.0.11 120 3/10/2026
4.0.10 24,770 3/10/2026
4.0.9 114 3/9/2026
4.0.8 119 3/9/2026
4.0.7 111 3/9/2026
4.0.5 281,210 2/4/2026
4.0.4 117 2/4/2026
Loading failed

Update actions/checkout action to v7 (#102)

Automatically merged