summaryrefslogtreecommitdiff
path: root/src/syncedsettings.h
diff options
context:
space:
mode:
authorChristian Glöckner <cgloeckner@freenet.de>2016-03-31 10:21:18 +0200
committerChristian Glöckner <cgloeckner@freenet.de>2016-03-31 10:21:18 +0200
commit6489719f4bf6f1f65af706986d3878c6fb3080b4 (patch)
treec46df4d624f3072e960b56831db2f24562bdc235 /src/syncedsettings.h
parent94961f8134c85981df467c70ee65a599f87a0bcb (diff)
Added explicit cpy/mv assign operators to be sure about thread-safety of Group<T>
Diffstat (limited to 'src/syncedsettings.h')
-rw-r--r--src/syncedsettings.h24
1 files changed, 22 insertions, 2 deletions
diff --git a/src/syncedsettings.h b/src/syncedsettings.h
index e60eb78..4991627 100644
--- a/src/syncedsettings.h
+++ b/src/syncedsettings.h
@@ -76,7 +76,6 @@ public:
: mutex{}
, data{}
{
- std::lock_guard<std::mutex> lock{mutex};
std::lock_guard<std::mutex> lock{other.mutex};
data = other.data;
}
@@ -85,11 +84,32 @@ public:
: mutex{}
, data{}
{
- std::lock_guard<std::mutex> lock{mutex};
std::lock_guard<std::mutex> lock{other.mutex};
std::swap(data, other.data);
}
+ Group<T>& operator=(const Group<T>& other)
+ {
+ if (*this != &other)
+ {
+ std::lock_guard<std::mutex> lock{mutex};
+ std::lock_guard<std::mutex> lock{other.mutex};
+ data = other.data;
+ }
+ return *this;
+ }
+
+ Group<T>& operator=(Group<T>&& other)
+ {
+ if (*this != &other)
+ {
+ std::lock_guard<std::mutex> lock{mutex};
+ std::lock_guard<std::mutex> lock{other.mutex};
+ std::swap(data, tmp.data);
+ }
+ return *this;
+ }
+
operator T() const
{
std::lock_guard<std::mutex> lock{mutex};