aboutsummaryrefslogtreecommitdiffstats
path: root/src/libs/3rdparty/botan/src/lib/utils/mutex.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/libs/3rdparty/botan/src/lib/utils/mutex.h')
-rw-r--r--src/libs/3rdparty/botan/src/lib/utils/mutex.h58
1 files changed, 58 insertions, 0 deletions
diff --git a/src/libs/3rdparty/botan/src/lib/utils/mutex.h b/src/libs/3rdparty/botan/src/lib/utils/mutex.h
new file mode 100644
index 0000000000..34fed5c81e
--- /dev/null
+++ b/src/libs/3rdparty/botan/src/lib/utils/mutex.h
@@ -0,0 +1,58 @@
+/*
+* (C) 2016 Jack Lloyd
+*
+* Botan is released under the Simplified BSD License (see license.txt)
+*/
+
+#ifndef BOTAN_UTIL_MUTEX_H_
+#define BOTAN_UTIL_MUTEX_H_
+
+#include <botan/types.h>
+
+#if defined(BOTAN_TARGET_OS_HAS_THREADS)
+
+#include <mutex>
+
+namespace Botan {
+
+template<typename T> using lock_guard_type = std::lock_guard<T>;
+typedef std::mutex mutex_type;
+
+}
+
+#else
+
+// No threads
+
+namespace Botan {
+
+template<typename Mutex>
+class lock_guard final
+ {
+ public:
+ explicit lock_guard(Mutex& m) : m_mutex(m)
+ { m_mutex.lock(); }
+
+ ~lock_guard() { m_mutex.unlock(); }
+
+ lock_guard(const lock_guard& other) = delete;
+ lock_guard& operator=(const lock_guard& other) = delete;
+ private:
+ Mutex& m_mutex;
+ };
+
+class noop_mutex final
+ {
+ public:
+ void lock() {}
+ void unlock() {}
+ };
+
+typedef noop_mutex mutex_type;
+template<typename T> using lock_guard_type = lock_guard<T>;
+
+}
+
+#endif
+
+#endif