Botan 2.19.5 Crypto and TLS for C&

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 typedef std::recursive_mutex recursive_mutex_type;
21
22}
23
24#else
25
26// No threads
27
28 namespace Botan {
29
30 template<typename Mutex>
31 class lock_guard final
32 {
33 public:
34 explicit lock_guard(Mutex& m) : m_mutex(m)
35 { m_mutex.lock(); }
36
37 ~lock_guard() { m_mutex.unlock(); }
38
39 lock_guard(const lock_guard& other) = delete;
40 lock_guard& operator=(const lock_guard& other) = delete;
41 private:
42 Mutex& m_mutex;
43 };
44
45 class noop_mutex final
46 {
47 public:
48 void lock() {}
49 void unlock() {}
50 };
51
52 typedef noop_mutex mutex_type;
53 typedef noop_mutex recursive_mutex_type;
54 template<typename T> using lock_guard_type = lock_guard<T>;
55
56}
57
58#endif
59
60#endif
Botan::lock_guard
Definition: mutex.h:32
Botan::lock_guard::lock_guard
lock_guard(Mutex &m)
Definition: mutex.h:34
Botan::lock_guard::operator=
lock_guard & operator=(const lock_guard &other)=delete
Botan::lock_guard::~lock_guard
~lock_guard()
Definition: mutex.h:37
Botan::lock_guard::lock_guard
lock_guard(const lock_guard &other)=delete
Botan::noop_mutex
Definition: mutex.h:46
Botan::noop_mutex::lock
void lock()
Definition: mutex.h:48
Botan::noop_mutex::unlock
void unlock()
Definition: mutex.h:49
final
int(* final)(unsigned char *, CTX *)
Definition: commoncrypto_hash.cpp:29
Botan
Definition: alg_id.cpp:13
Botan::lock_guard_type
lock_guard< T > lock_guard_type
Definition: mutex.h:54
Botan::recursive_mutex_type
noop_mutex recursive_mutex_type
Definition: mutex.h:53
Botan::mutex_type
noop_mutex mutex_type
Definition: mutex.h:52