SiddiqSoft.RWLContainer 1.5.3

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


Classes and Methods

RWLContainer

A thread-safe dictionary with reader-writer locking for efficient concurrent access.

RWLContainer<KeyType, StorageType>
├── Configuration
│   ├── ReplaceExisting
│   └── FailOnCollission
├── Methods
│   ├── add(key, value)
│   ├── add(key, shared_ptr)
│   ├── add(key, callback)
│   ├── remove(key)
│   ├── find(key)
│   ├── size()
│   ├── scan(callback)
│   └── toJson()
└── Properties
    ├── addCounter
    └── removeCounter

RWLContainer Methods

Method Description Link
add(key, StorageType&&) Add element by moving value Details
add(key, StorageTypePtr&&) Add element via shared_ptr Details
add(key, callback) Add element via callback Details
remove(key) Remove and return element Details
find(key) Find element without removing Details
size() Get number of elements Details
scan(callback) Iterate and find elements Details
toJson() Serialize to JSON Details

WaitableQueue

A thread-safe queue with timeout-based waiting for producer-consumer patterns.

WaitableQueue<StorageType>
├── Methods
│   ├── push(value)
│   ├── emplace(value)
│   ├── tryWaitItem(timeout)
│   ├── waitUntilEmpty(timeout)
│   ├── size()
│   ├── addCounter()
│   ├── removeCounter()
│   └── toJson()
└── Properties
    ├── Deleted: copy constructor
    ├── Deleted: move constructor
    ├── Deleted: copy assignment
    └── Deleted: move assignment

WaitableQueue Methods

Method Description Link
push(StorageType&&) Add element to queue Details
emplace(StorageType&&) Construct element in-place Details
tryWaitItem(timeout) Wait for element with timeout Details
waitUntilEmpty(timeout) Wait until queue is empty Details
size() Get number of elements Details
addCounter() Get total adds Details
removeCounter() Get total removes Details
toJson() Serialize to JSON Details

API Documentation

For detailed API documentation, method signatures, and comprehensive examples, see API.md and some notes on tests.

Usage

Quick Example: RWLContainer

#include "siddiqsoft/RWLContainer.hpp"

int main() {
    siddiqsoft::RWLContainer<std::string, int> cache;
    
    // Add items
    cache.add("count", 42);
    cache.add("value", 100);
    
    // Find items
    if (auto val = cache.find("count")) {
        std::cout << "Found: " << *val << std::endl;
    }
    
    // Remove items
    cache.remove("count");
    
    std::cout << "Size: " << cache.size() << std::endl;
    
    return 0;
}

Quick Example: WaitableQueue

#include "siddiqsoft/WaitableQueue.hpp"
#include <thread>

int main() {
    siddiqsoft::WaitableQueue<std::string> queue;
    
    // Producer thread
    std::thread producer([&queue]() {
        for (int i = 0; i < 5; ++i) {
            queue.push(std::string("item_") + std::to_string(i));
        }
    });
    
    // Consumer thread
    std::thread consumer([&queue]() {
        while (true) {
            auto item = queue.tryWaitItem(std::chrono::milliseconds(500));
            if (item) {
                std::cout << "Processed: " << *item << std::endl;
            } else {
                break;
            }
        }
    });
    
    producer.join();
    consumer.join();
    
    return 0;
}

Versioning

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


<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.5.3 90 6/29/2026
1.5.2 89 6/29/2026
1.4.9 92 6/29/2026
1.4.8 88 6/28/2026
1.4.7 101 6/28/2026
1.4.6 92 6/27/2026
1.4.5 146 5/22/2026
1.4.4 174 5/1/2026
1.3.2 533 12/17/2024
1.3.1 471 12/16/2024
1.3.0 462 12/15/2024
1.2.0 461 12/7/2024
1.1.3 1,055 11/20/2021
1.1.2 821 7/22/2021
1.1.1 833 7/22/2021