3 * @Author Tu Yongce <yongce (at) 126 (dot) com>
9 #ifndef SHARED_MUTEX_H_INCLUDED
10 #define SHARED_MUTEX_H_INCLUDED
13 #error "works only on Windows"
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;
38 // SharedMutex(SharedMutex &mutex);
39 // SharedMutex & operator = (SharedMutex &mutex);
45 bool AcquireShared(DWORD waitTime
= INFINITE
);
47 bool AcquireShared(DWORD waitTime
= 500);
54 bool AcquireExclusive(DWORD waitTime
= INFINITE
);
56 bool AcquireExclusive(DWORD waitTime
= 500);
59 void ReleaseExclusive();
62 #endif // SHARED_MUTEX_H_INCLUDED