SiddiqSoft.RWLContainer
1.5.3
dotnet add package SiddiqSoft.RWLContainer --version 1.5.3
NuGet\Install-Package SiddiqSoft.RWLContainer -Version 1.5.3
<PackageReference Include="SiddiqSoft.RWLContainer" Version="1.5.3" />
<PackageVersion Include="SiddiqSoft.RWLContainer" Version="1.5.3" />
<PackageReference Include="SiddiqSoft.RWLContainer" />
paket add SiddiqSoft.RWLContainer --version 1.5.3
#r "nuget: SiddiqSoft.RWLContainer, 1.5.3"
#:package SiddiqSoft.RWLContainer@1.5.3
#addin nuget:?package=SiddiqSoft.RWLContainer&version=1.5.3
#tool nuget:?package=SiddiqSoft.RWLContainer&version=1.5.3
RWLContainer : Reader-writer protected containers
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_mapwithstd::shared_mutexfor safe concurrent access - WaitableQueue: A thread-safe queue that augments
std::queuewithstd::shared_mutexandstd::counting_semaphorefor efficient producer-consumer patterns
These classes eliminate boilerplate synchronization code and provide a simple, type-safe API for common concurrent programming scenarios.
Requirements
- C++20 or later
<shared_mutex>and<mutex>support- CMake 3.20+
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
- Use the nuget SiddiqSoft.RWLContainer
- Use CPM to integrate into your CMake project
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 | Versions Compatible and additional computed target framework versions. |
|---|---|
| native | native is compatible. |
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 |