Botan: src/mutex/mutex.h Source File

Botan 1.10.12

- Main Page
- Related Pages
- Namespaces
- Classes
- Files

- File List
- File Members

mutex.h
Go to the documentation of this file.
1 /*
2 * Mutex
3 * (C) 1999-2007 Jack Lloyd
4 *
5 * Distributed under the terms of the Botan license
6 */
7
8 #ifndef BOTAN_MUTEX_H__
9 #define BOTAN_MUTEX_H__
10
11 #include <botan/exceptn.h>
12
13 namespace Botan {
14
15 /**
16 * Mutex Base Class
17 */
18 class Mutex
19 {
20 public:
21 /**
22 * Lock the mutex
23 */
24 virtual void lock() = 0;
25
26 /**
27 * Unlock the mutex
28 */
29 virtual void unlock() = 0;
30 virtual ~Mutex() {}
31 };
32
33 /**
34 * Mutex Factory
35 */
36 class Mutex_Factory
37 {
38 public:
39 /**
40 * @return newly allocated mutex
41 */
42 virtual Mutex* make() = 0;
43
44 virtual ~Mutex_Factory() {}
45 };
46
47 /**
48 * Mutex Holding Class for RAII
49 */
50 class Mutex_Holder
51 {
52 public:
53 /**
54 * Hold onto a mutex until we leave scope
55 * @param m the mutex to lock
56 */
57 Mutex_Holder(Mutex* m) : mux(m)
58 {
59 if(!mux)
60 throw Invalid_Argument("Mutex_Holder: Argument was NULL");
61 mux->lock();
62 }
63
64 ~Mutex_Holder() { mux->unlock(); }
65 private:
66 Mutex* mux;
67 };
68
69 }
70
71 #endif
Botan::Mutex_Holder::~Mutex_Holder
~Mutex_Holder()
Definition: mutex.h:64
Botan::Mutex::~Mutex
virtual ~Mutex()
Definition: mutex.h:30
Botan::Mutex_Factory
Definition: mutex.h:36
Botan::Mutex::lock
virtual void lock()=0
Botan::Invalid_Argument
std::invalid_argument Invalid_Argument
Definition: exceptn.h:20
Botan::Mutex::unlock
virtual void unlock()=0
m
endian little unaligned ok family x86< aliases > ia32 x86 ix86 i86pc x86pc bepc</aliases >< submodels > i386 i486 i586 i686 pentium2 pentium3 pentium4 pentium m prescott k6 athlon atom32</submodels >< submodel_aliases > pentium i586 pentiumpro i686 pentium_pro i686 pentium2 pentium2 pentiumii pentium2 pentium3 pentium3 pentiumiii pentium3 x86family5 i586 x86family6 i686 pentiumm pentium m intelpentiumm pentium m intelpentium4 pentium4 duron athlon athlon xp athlon k7 athlon p2 i686 p3 i686 p4 pentium4 intelcput2250 prescott intelcput2300 prescott intelcput2400 prescott intelcput2500 prescott intelcput2600 prescott intelcput2700 prescott</submodel_aliases >< isa_extn > pentium m
Definition: x86_32.txt:65
Botan
Definition: algo_base.h:14
Botan::Mutex_Holder::Mutex_Holder
Mutex_Holder(Mutex *m)
Definition: mutex.h:57
Botan::Mutex
Definition: mutex.h:18
Botan::Mutex_Holder
Definition: mutex.h:50
Botan::Mutex_Factory::~Mutex_Factory
virtual ~Mutex_Factory()
Definition: mutex.h:44