Botan 2.13.0 Crypto and TLS for C++11

- Main Page
- Namespaces
- Classes
- Files

- File List
- File Members

mutex.h
Go to the documentation of this file.
1 /*
2 * (C) 2016 Jack Lloyd
3 *
4 * Botan is released under the Simplified BSD License (see license.txt)
5 */
6
7 #ifndef BOTAN_UTIL_MUTEX_H_
8 #define BOTAN_UTIL_MUTEX_H_
9
10 #include <botan/types.h>
11
12 #if defined(BOTAN_TARGET_OS_HAS_THREADS)
13
14 #include <mutex>
15
16 namespace Botan {
17
18 template<typename T> using lock_guard_type = std::lock_guard<T>;
19 typedef std::mutex mutex_type;
20
21 }
22
23 #else
24
25 // No threads
26
27 namespace Botan {
28
29 template<typename Mutex>
30 class lock_guard final
31 {
32 public:
33 explicit lock_guard(Mutex& m) : m_mutex(m)
34 { m_mutex.lock(); }
35
36 ~lock_guard() { m_mutex.unlock(); }
37
38 lock_guard(const lock_guard& other) = delete;
39 lock_guard& operator=(const lock_guard& other) = delete;
40 private:
41 Mutex& m_mutex;
42 };
43
44 class noop_mutex final
45 {
46 public:
47 void lock() {}
48 void unlock() {}
49 };
50
51 typedef noop_mutex mutex_type;
52 template<typename T> using lock_guard_type = lock_guard<T>;
53
54 }
55
56 #endif
57
58 #endif
Botan::mutex_type
noop_mutex mutex_type
Definition: mutex.h:51
final
int(* final)(unsigned char *, CTX *)
Definition: commoncrypto_hash.cpp:28
Botan::noop_mutex::unlock
void unlock()
Definition: mutex.h:48
Botan::noop_mutex
Definition: mutex.h:44
Botan::lock_guard::~lock_guard
~lock_guard()
Definition: mutex.h:36
Botan::noop_mutex::lock
void lock()
Definition: mutex.h:47
Botan::lock_guard
Definition: mutex.h:30
Botan::lock_guard::lock_guard
lock_guard(Mutex &m)
Definition: mutex.h:33
Botan::lock_guard::operator=
lock_guard & operator=(const lock_guard &other)=delete
Botan
Definition: alg_id.cpp:13
Botan::lock_guard_type
lock_guard< T > lock_guard_type
Definition: mutex.h:52