Thread-Safe C++20 Containers
A thread-safe dictionary with reader-writer locking for efficient concurrent access.
ReplaceExisting - Replace on collisionFailOnCollission - Fail on collisionadd(key, value) - Add by valueadd(key, shared_ptr) - Add by pointeradd(key, callback) - Add via callbackremove(key) - Remove and returnfind(key) - Find without removingsize() - Get element countscan(callback) - Iterate and findtoJson() - Serialize metadataA thread-safe queue for producer-consumer patterns with timeout support.
push(value) - Add to queueemplace(value) - Construct in-placetryWaitItem(timeout) - Wait for itemwaitUntilEmpty(timeout) - Wait until emptysize() - Get queue sizeaddCounter() - Total addsremoveCounter() - Total removestoJson() - Serialize metadataInstallation:
# Using NuGet (Windows)
nuget install SiddiqSoft.RWLContainer
# Using CPM (CMake)
CPMAddPackage("gh:SiddiqSoft/RWLContainer@1.5.3")
RWLContainer Example:
#include "siddiqsoft/RWLContainer.hpp"
int main() {
siddiqsoft::RWLContainer<std::string, int> cache;
cache.add("key1", 42);
if (auto value = cache.find("key1")) {
std::cout << "Value: " << *value << std::endl;
}
cache.remove("key1");
return 0;
}
WaitableQueue Example:
#include "siddiqsoft/WaitableQueue.hpp"
int main() {
siddiqsoft::WaitableQueue<std::string> queue;
std::thread producer([&]() {
queue.push("item1");
queue.push("item2");
});
std::thread consumer([&]() {
while (auto item = queue.tryWaitItem(std::chrono::milliseconds(500))) {
std::cout << "Got: " << *item << std::endl;
}
});
producer.join();
consumer.join();
return 0;
}
📖 More Examples: See Examples.md and Getting-Started.md for detailed usage patterns.