SiddiqSoft.RWLContainer 1.4.4

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

RWLContainer : Reader-writer protected containers

Build Status 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

Overview

This library provides convenient, production-ready wrappers around C++20 standard library synchronization primitives:

  • RWLContainer: A reader-writer lock protected dictionary that wraps std::unordered_map with std::shared_mutex for safe concurrent access
  • WaitableQueue: A thread-safe queue that augments std::queue with std::shared_mutex and std::counting_semaphore for efficient producer-consumer patterns

These classes eliminate boilerplate synchronization code and provide a simple, type-safe API for common concurrent programming scenarios.

Requirements

Platform Support

Tested and built on:

  • Windows (Visual Studio 2022)
  • Linux (Fedora)
  • macOS

All platforms are tested in the CI/CD pipeline with comprehensive test coverage.

Testing

  • Unit tests using Google Test (gtest)
  • Code coverage reporting (Linux builds)
  • Automated testing on all supported platforms via Azure Pipelines
  • Stress testing included in test suite

Known Test Behavior

ConcurrentScanAndWrite Test: This stress test exercises concurrent scanning and writing operations on the RWLContainer. Due to platform-specific differences in std::shared_mutex implementations:

  • Linux (x86_64 and ARM64): The test includes a timeout mechanism (100ms) to prevent potential deadlocks. The scan callback will exit early if it exceeds the timeout, allowing the test to complete successfully.
  • Windows (ARM64) and macOS: The test runs without timeout restrictions and completes normally without deadlock issues.

This difference is due to variations in how different platforms implement reader-writer lock fairness and priority inversion handling. The timeout mechanism ensures the test remains robust across all platforms while still validating the thread-safety of concurrent operations.

WaitUntilEmptyTightLoopContention Test: This stress test for WaitableQueue exercises tight-loop contention between multiple threads calling waitUntilEmpty() while concurrent push/pop operations occur. Due to platform-specific differences in std::shared_mutex implementations:

  • Linux (x86_64 and ARM64): The test is skipped or may experience deadlocks due to lock fairness issues under extreme contention. The tight loop with minimal timeouts (1ms) can cause priority inversion on Linux's shared_mutex implementation.
  • Windows (ARM64) and macOS: The test runs without issues and completes normally, demonstrating robust handling of concurrent wait and mutation operations.

This difference reflects variations in how different platforms prioritize reader vs. writer threads in shared_mutex implementations. The library's core functionality remains thread-safe on all platforms; this test specifically stresses an edge case that manifests differently across platforms.

Versioning

Uses GitVersion for semantic versioning (MAJOR.MINOR.PATCH). Version is automatically determined from git history.

API Documentation

For detailed API documentation, method signatures, and comprehensive examples, see API.md.

Usage

Quick Example

#include "gtest/gtest.h"
#include "nlohmann/json.hpp"
#include "siddiqsoft/RWLContainer.hpp"

TEST(examples, Example1)
{
    try
    {
        siddiqsoft::RWLContainer<std::string, std::string> myContainer;

        auto item = myContainer.add("foo", "bar");
        ASSERT_TRUE(item);
        EXPECT_EQ("bar", *item);
    }
    catch (...)
    {
        EXPECT_TRUE(false); // if we throw then the test fails.
    }
}

<small align="right">

© 2021 Siddiq Software LLC. All rights reserved.

</small>

Product Compatible and additional computed target framework versions.
native native is compatible. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

This package has no dependencies.

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
1.4.4 111 5/1/2026
1.3.2 475 12/17/2024
1.3.1 412 12/16/2024
1.3.0 405 12/15/2024
1.2.0 404 12/7/2024
1.1.3 999 11/20/2021
1.1.2 765 7/22/2021
1.1.1 779 7/22/2021