summaryrefslogtreecommitdiff
path: root/src/threading/mutex_auto_lock.h
diff options
context:
space:
mode:
authorest31 <MTest31@outlook.com>2016-01-23 05:45:00 +0100
committerest31 <MTest31@outlook.com>2016-01-23 05:45:29 +0100
commite50c784e2ca55735fc360ae51534288c2ea59ca5 (patch)
tree5460f36ef2e8a72ac629548f027956f055502bf1 /src/threading/mutex_auto_lock.h
parent0459eca8eb2e73e9670e00b838dabc9347acb35f (diff)
downloadminetest-e50c784e2ca55735fc360ae51534288c2ea59ca5.tar.gz
minetest-e50c784e2ca55735fc360ae51534288c2ea59ca5.tar.bz2
minetest-e50c784e2ca55735fc360ae51534288c2ea59ca5.zip
Fix C++11 compilability
Previous commits broke it... :(
Diffstat (limited to 'src/threading/mutex_auto_lock.h')
-rw-r--r--src/threading/mutex_auto_lock.h12
1 files changed, 11 insertions, 1 deletions
diff --git a/src/threading/mutex_auto_lock.h b/src/threading/mutex_auto_lock.h
index 1c39349e5..25caf7e14 100644
--- a/src/threading/mutex_auto_lock.h
+++ b/src/threading/mutex_auto_lock.h
@@ -28,7 +28,8 @@ DEALINGS IN THE SOFTWARE.
#if __cplusplus >= 201103L
#include <mutex>
- using MutexAutoLock = std::lock_guard<std::mutex>;
+ using MutexAutoLock = std::unique_lock<std::mutex>;
+ using RecursiveMutexAutoLock = std::unique_lock<std::recursive_mutex>;
#else
#include "threading/mutex.h"
@@ -44,6 +45,15 @@ private:
Mutex &mutex;
};
+class RecursiveMutexAutoLock
+{
+public:
+ RecursiveMutexAutoLock(RecursiveMutex &m) : mutex(m) { mutex.lock(); }
+ ~RecursiveMutexAutoLock() { mutex.unlock(); }
+
+private:
+ RecursiveMutex &mutex;
+};
#endif
#endif