diff options
author | Loïc Blot <nerzhul@users.noreply.github.com> | 2017-04-20 00:12:52 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-04-20 00:12:52 +0200 |
commit | f98bbe193e0093aca8d8957cec82fdbd28639915 (patch) | |
tree | 19879fbca595d4e8cddfa8d7d069b7f78016a713 /src/util/thread.h | |
parent | f3fe62a0bf9e775b3e6e838f104ab605a2238792 (diff) | |
download | minetest-f98bbe193e0093aca8d8957cec82fdbd28639915.tar.gz minetest-f98bbe193e0093aca8d8957cec82fdbd28639915.tar.bz2 minetest-f98bbe193e0093aca8d8957cec82fdbd28639915.zip |
Fix various copy instead of const ref reported by cppcheck (part 3) (#5616)
* Also remove 2 non declared but defined functions
* Make some functions around const ref changes const
Diffstat (limited to 'src/util/thread.h')
-rw-r--r-- | src/util/thread.h | 14 |
1 files changed, 4 insertions, 10 deletions
diff --git a/src/util/thread.h b/src/util/thread.h index d43e06e0a..f54b8b48f 100644 --- a/src/util/thread.h +++ b/src/util/thread.h @@ -29,9 +29,10 @@ with this program; if not, write to the Free Software Foundation, Inc., #include "container.h" template<typename T> -class MutexedVariable { +class MutexedVariable +{ public: - MutexedVariable(T value): + MutexedVariable(const T &value): m_value(value) {} @@ -41,21 +42,14 @@ public: return m_value; } - void set(T value) + void set(const T &value) { MutexAutoLock lock(m_mutex); m_value = value; } - // You'll want to grab this in a SharedPtr - MutexAutoLock *getLock() - { - return new MutexAutoLock(m_mutex); - } - // You pretty surely want to grab the lock when accessing this T m_value; - private: Mutex m_mutex; }; |