Remove extra tab
[TortoiseGit.git] / src / Git / SharedMutex.h
blob9d6290a64eb4ade9f2bd7bdc5dee63bb3a56e898
1 /**
2 * SharedMutex.h
3 * @Author Tu Yongce <yongce (at) 126 (dot) com>
4 * @Created 2008-11-17
5 * @Modified 2008-11-17
6 * @Version 0.1
7 */
9 #ifndef SHARED_MUTEX_H_INCLUDED
10 #define SHARED_MUTEX_H_INCLUDED
12 #ifndef _WIN32
13 #error "works only on Windows"
14 #endif
16 #include <windows.h>
18 // ¿É¹²ÏíµÄ»¥³âÁ¿
19 class SharedMutex
21 private:
22 HANDLE m_mutex;
23 HANDLE m_sharedEvent;
24 HANDLE m_exclusiveEvent;
26 volatile int m_sharedNum;
27 volatile int m_exclusiveNum;
28 volatile int m_lockType;
30 static const int LOCK_NONE = 0;
31 static const int LOCK_SHARED = 1;
32 static const int LOCK_EXCLUSIVE = 2;
34 public:
35 SharedMutex();
36 void Init();
37 void Release();
38 // SharedMutex(SharedMutex &mutex);
39 // SharedMutex & operator = (SharedMutex &mutex);
41 ~SharedMutex();
43 // »ñÈ¡¹²Ïí·ÃÎÊȨ
44 #ifdef DEBUG
45 bool AcquireShared(DWORD waitTime = INFINITE);
46 #else
47 bool AcquireShared(DWORD waitTime = 500);
48 #endif
49 // ÊͷŹ²Ïí·ÃÎÊȨ
50 void ReleaseShared();
52 // »ñÈ¡¶ÀÕ¼·ÃÎÊȨ
53 #ifdef DEBUG
54 bool AcquireExclusive(DWORD waitTime = INFINITE);
55 #else
56 bool AcquireExclusive(DWORD waitTime = 500);
57 #endif
58 // ÊͷŶÀÕ¼·ÃÎÊȨ
59 void ReleaseExclusive();
62 #endif // SHARED_MUTEX_H_INCLUDED