CounterpointCollective.CoalescingQueue 10.1.128

dotnet add package CounterpointCollective.CoalescingQueue --version 10.1.128
                    
NuGet\Install-Package CounterpointCollective.CoalescingQueue -Version 10.1.128
                    
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="CounterpointCollective.CoalescingQueue" Version="10.1.128" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="CounterpointCollective.CoalescingQueue" Version="10.1.128" />
                    
Directory.Packages.props
<PackageReference Include="CounterpointCollective.CoalescingQueue" />
                    
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 CounterpointCollective.CoalescingQueue --version 10.1.128
                    
#r "nuget: CounterpointCollective.CoalescingQueue, 10.1.128"
                    
#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 CounterpointCollective.CoalescingQueue@10.1.128
                    
#: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=CounterpointCollective.CoalescingQueue&version=10.1.128
                    
Install as a Cake Addin
#tool nuget:?package=CounterpointCollective.CoalescingQueue&version=10.1.128
                    
Install as a Cake Tool

CounterpointCollective.CoalescingQueue

Efficient, thread-safe coalescing queue implementation for .NET 10, designed for high-throughput scenarios where duplicate work items should be merged and resource usage optimized.

Api documentation

Features

  • Coalescing behavior: Automatically merges duplicate or similar items, reducing redundant processing.
  • Thread-safe: Safe for concurrent producers and consumers.
  • Object pooling: Utilizes Microsoft.Extensions.ObjectPool for efficient memory management.
  • Integration: Designed to work seamlessly with other primitives in the PrestoPrimitives suite.

Getting Started

Prerequisites

Installation

Add the NuGet package to your project:

dotnet add package CounterpointCollective.CoalescingQueue

Usage Example:

// Example event type
class HitEvent
{
    private volatile int damage;
    public int Damage => damage;
    public void AddDamage(int amount) => Interlocked.Add(ref damage, amount);
}

[TestMethod]
public async Task Example()
{
    int dispatchCount = 0;
    int hitPoints = 100;
    var queue = new CoalescingQueue();


    // Handle for HitEvent, coalescing enabled
    var handle = queue.CreateHandle<HitEvent>(
        coalesceConsecutiveItems: true,
        dispatcher: e => {
            dispatchCount++;
            hitPoints -= e.Damage;
        });

    // Rapid updates � looks like two enqueues, but coalesces into one
    var node1 = handle.Enqueue();
    var node2 = handle.Enqueue();
    node1.ClaimValue().AddDamage(5);
    node1.Dispose();
    node2.ClaimValue().AddDamage(3);
    node2.Dispose();

    await queue.ProcessPendingAsync();
    Assert.AreEqual(1, dispatchCount);  // Only one dispatch happens
    await Task.Delay(10); // Ensure all updates are processed
    Assert.AreEqual(92, hitPoints); // 100 - (5 + 3)
}

API Highlights

  • CoalescingQueue<T>: Main queue type supporting enqueue, dequeue, and coalescing logic.
  • Extension methods for dispatching and pooling.

Project Structure

  • CoalescingQueue.cs: Core queue implementation.
  • Pool.cs: Object pooling utilities.
  • CoalescingQueueDispatchExtensions.cs: Extensions for dispatching work.

License

MIT

Repository

GitLab - PrestoPrimitives


Maintained by CounterpointCollective.

Product Compatible and additional computed target framework versions.
.NET 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. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages (2)

Showing the top 2 NuGet packages that depend on CounterpointCollective.CoalescingQueue:

Package Downloads
CounterpointCollective.ComposableDataflowBlocks

Composable dataflow blocks for building robust, reusable data processing pipelines in .NET.

CounterpointCollective.Dataflow.Composable

Composable dataflow blocks for building robust, reusable data processing pipelines in .NET.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
10.1.128 86 1/17/2026
10.1.126 90 12/29/2025
10.1.124 95 12/29/2025