Changeset 33:0eefa89dec31 in xplcommon


Ignore:
Timestamp:
01/02/13 15:06:40 (12 years ago)
Author:
István Váradi <ivaradi@…>
Branch:
default
Phase:
public
Message:

Reimplemented to use a critical section

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/xplcommon/win32/Mutex.h

    r32 r33  
    4949     * The handle of the mutex.
    5050     */
    51     HANDLE mutex;
     51    CRITICAL_SECTION mutex;
    5252
    5353public:
     
    8585//------------------------------------------------------------------------------
    8686
    87 inline Mutex::Mutex() :
    88     mutex(CreateMutex(0, false, 0))
     87inline Mutex::Mutex()
    8988{
     89    InitializeCriticalSection(&mutex);
    9090}
    9191
     
    9494inline Mutex::~Mutex()
    9595{
    96     CloseHandle(mutex);
     96    DeleteCriticalSection(&mutex);
    9797}
    9898
     
    101101inline void Mutex::lock()
    102102{
    103     WaitForSingleObject(mutex, INFINITE);
     103    EnterCriticalSection(&mutex);
    104104}
    105105
     
    108108inline bool Mutex::tryLock()
    109109{
    110     return WaitForSingleObject(mutex, 0) == WAIT_OBJECT_0;
     110    return TryEnterCriticalSection(&mutex);
    111111}
    112112
     
    115115inline void Mutex::unlock()
    116116{
    117     ReleaseMutex(mutex);
     117    LeaveCriticalSection(&mutex);
    118118}
    119119
Note: See TracChangeset for help on using the changeset viewer.