version 1.8, 2006/10/03 17:34:53
|
version 1.9, 2006/12/01 21:31:45
|
|
|
static inline void _initialize(MutexRep& rep) | static inline void _initialize(MutexRep& rep) |
{ | { |
rep.handle = CreateMutex(NULL, FALSE, NULL); | rep.handle = CreateMutex(NULL, FALSE, NULL); |
#if defined(PEGASUS_DEBUG) |
|
rep.count = 0; | rep.count = 0; |
#endif |
|
} | } |
| |
Mutex::Mutex() | Mutex::Mutex() |
|
|
if (rc == WAIT_FAILED) | if (rc == WAIT_FAILED) |
throw WaitFailed(Threads::self()); | throw WaitFailed(Threads::self()); |
| |
#if defined(PEGASUS_DEBUG) |
|
_rep.count++; | _rep.count++; |
#endif |
|
} | } |
| |
void Mutex::try_lock() | void Mutex::try_lock() |
|
|
if (rc == WAIT_FAILED) | if (rc == WAIT_FAILED) |
throw WaitFailed(Threads::self()); | throw WaitFailed(Threads::self()); |
| |
#if defined(PEGASUS_DEBUG) |
|
_rep.count++; | _rep.count++; |
#endif |
|
} | } |
| |
void Mutex::timed_lock(Uint32 milliseconds) | void Mutex::timed_lock(Uint32 milliseconds) |
|
|
if (rc == WAIT_FAILED) | if (rc == WAIT_FAILED) |
throw WaitFailed(Threads::self()); | throw WaitFailed(Threads::self()); |
| |
#if defined(PEGASUS_DEBUG) |
|
_rep.count++; | _rep.count++; |
#endif |
|
} | } |
| |
void Mutex::unlock() | void Mutex::unlock() |
|
|
PEGASUS_DEBUG_ASSERT(_magic); | PEGASUS_DEBUG_ASSERT(_magic); |
PEGASUS_DEBUG_ASSERT(_rep.count > 0); | PEGASUS_DEBUG_ASSERT(_rep.count > 0); |
| |
#if defined(PEGASUS_DEBUG) |
|
_rep.count--; | _rep.count--; |
#endif |
|
ReleaseMutex(_rep.handle); | ReleaseMutex(_rep.handle); |
} | } |
| |