Update README.md
[nemesis.git] / Platform / Mutex.h
1 /*
2  Copyright (c) 2008 TrueCrypt Developers Association. All rights reserved.
3
4  Governed by the TrueCrypt License 3.0 the full text of which is contained in
5  the file License.txt included in TrueCrypt binary and source code distribution
6  packages.
7 */
8
9 #ifndef TC_HEADER_Platform_Mutex
10 #define TC_HEADER_Platform_Mutex
11
12 #ifdef TC_WINDOWS
13 #       include "System.h"
14 #else
15 #       include <pthread.h>
16 #endif
17 #include "PlatformBase.h"
18
19 namespace TrueCrypt
20 {
21         class Mutex
22         {
23 #ifdef TC_WINDOWS
24                 typedef CRITICAL_SECTION SystemMutex_t;
25 #else
26                 typedef pthread_mutex_t SystemMutex_t;
27 #endif
28
29         public:
30                 Mutex ();
31                 ~Mutex ();
32
33                 SystemMutex_t *GetSystemHandle () { return &SystemMutex; }
34                 void Lock ();
35                 void Unlock ();
36
37         protected:
38                 bool Initialized;
39                 SystemMutex_t SystemMutex;
40
41         private:
42                 Mutex (const Mutex &);
43                 Mutex &operator= (const Mutex &);
44         };
45
46         class ScopeLock
47         {
48         public:
49                 ScopeLock (Mutex &mutex) : ScopeMutex (mutex) { mutex.Lock(); }
50                 ~ScopeLock () { ScopeMutex.Unlock(); }
51
52         protected:
53                 Mutex &ScopeMutex;
54
55         private:
56                 ScopeLock (const ScopeLock &);
57                 ScopeLock &operator= (const ScopeLock &);
58         };
59 }
60
61 #endif // TC_HEADER_Platform_Mutex
This page took 0.028996 seconds and 3 git commands to generate. Download a nemesis OSX (sierra+high sierra, tested/working) binary, with fuse-ext3 via e2fsprogs, at this link. application and installer are signed by screwjack, llc. must install fuse with macFUSE layer first.