- Avoid re-implementing the rw-lock; standard C++ (since C++14) has a good reader-writer lock implementation.
- Provide a simple, convenience layer for dictionary containers.
- The storage type is a
std::shared_ptr<>
- You must be able to use
<shared_mutex>
and<mutex>
. - Minimal target is
C++17
. - The build and tests are for Visual Studio 2019 under x64.
- We use
nlohmann::json
only in our tests and the library is aware to provide a conversion operator if library is detected.
- Use the nuget SiddiqSoft.RWLContainer
- Copy paste..whatever works.
#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.
}
}
Additional examples.
© 2021 Siddiq Software LLC. All rights reserved.