diff options
author | Bent Bisballe Nyeng <deva@aasimon.org> | 2024-03-26 12:23:51 +0100 |
---|---|---|
committer | Bent Bisballe Nyeng <deva@aasimon.org> | 2024-03-26 12:23:51 +0100 |
commit | 6e461de50e73c0c957af73e5ee7a25f4d0293490 (patch) | |
tree | 03916b36c1cf0e25239b8d6cc0cf013b0fcb3697 /src/atomic.h | |
parent | 702e6907265035af031004f21ce09e3f62037fb4 (diff) |
Make all mutex locks const, as per linter warning
Diffstat (limited to 'src/atomic.h')
-rw-r--r-- | src/atomic.h | 20 |
1 files changed, 10 insertions, 10 deletions
diff --git a/src/atomic.h b/src/atomic.h index 7ca5d1e..a29eeee 100644 --- a/src/atomic.h +++ b/src/atomic.h @@ -69,7 +69,7 @@ public: : data{} , mutex{} { - std::lock_guard<std::mutex> lock{other.mutex}; + const std::lock_guard<std::mutex> lock{other.mutex}; data = other.data; } @@ -77,13 +77,13 @@ public: : data{} , mutex{} { - std::lock_guard<std::mutex> lock{other.mutex}; + const std::lock_guard<std::mutex> lock{other.mutex}; std::swap(data, other.data); } T operator=(T data) { - std::lock_guard<std::mutex> lock{mutex}; + const std::lock_guard<std::mutex> lock{mutex}; this->data = std::move(data); return this->data; } @@ -100,42 +100,42 @@ public: void store(T data) { - std::lock_guard<std::mutex> lock{mutex}; + const std::lock_guard<std::mutex> lock{mutex}; this->data = std::move(data); } T load() const { - std::lock_guard<std::mutex> lock{mutex}; + const std::lock_guard<std::mutex> lock{mutex}; return data; } T exchange(T data){ - std::lock_guard<std::mutex> lock{mutex}; + const std::lock_guard<std::mutex> lock{mutex}; std::swap(data, this->data); return data; } bool operator==(const T& other) const { - std::lock_guard<std::mutex> lock{mutex}; + const std::lock_guard<std::mutex> lock{mutex}; return other == data; } bool operator!=(const T& other) const { - std::lock_guard<std::mutex> lock{mutex}; + const std::lock_guard<std::mutex> lock{mutex}; return !(other == data); } bool operator==(const Atomic<T>& other) const { - std::lock_guard<std::mutex> lock{mutex}; + const std::lock_guard<std::mutex> lock{mutex}; return other.load() == data; } bool operator!=(const Atomic<T>& other) const { - std::lock_guard<std::mutex> lock{mutex}; + const std::lock_guard<std::mutex> lock{mutex}; return !(other.load() == data); } |