version 1.3.14.6, 2006/07/30 22:51:02
|
version 1.3.14.7, 2006/07/30 22:57:19
|
|
|
pthread_mutex_init(&_rep.mutex, &_attr); | pthread_mutex_init(&_rep.mutex, &_attr); |
} | } |
| |
|
Mutex::~Mutex() |
|
{ |
|
PEGASUS_DEBUG_ASSERT(_magic); |
|
pthread_mutex_destroy(&_rep.mutex); |
|
} |
|
|
void Mutex::try_lock() | void Mutex::try_lock() |
{ | { |
PEGASUS_DEBUG_ASSERT(_magic); | PEGASUS_DEBUG_ASSERT(_magic); |
|
|
} | } |
} | } |
| |
#if 0 |
|
void Mutex::unlock() |
|
{ |
|
PEGASUS_DEBUG_ASSERT(_magic); |
|
|
|
if (pthread_mutex_unlock(&_rep.mutex) != 0) |
|
throw Permission(ThreadType()); |
|
} |
|
#endif |
|
|
|
#endif /* PEGASUS_HAVE_PTHREADS */ | #endif /* PEGASUS_HAVE_PTHREADS */ |
| |
//============================================================================== | //============================================================================== |
|
|
{ | { |
_rep.handle = CreateMutex(NULL, FALSE, NULL); | _rep.handle = CreateMutex(NULL, FALSE, NULL); |
Threads::clear(ThreadType()); | Threads::clear(ThreadType()); |
_rep.count = 0; |
|
} | } |
| |
Mutex::~Mutex() | Mutex::~Mutex() |
|
|
CloseHandle(_rep.handle); | CloseHandle(_rep.handle); |
} | } |
| |
void Mutex::lock() |
|
{ |
|
PEGASUS_DEBUG_ASSERT(_magic); |
|
|
|
DWORD rc = WaitForSingleObject(_rep.handle, INFINITE); |
|
|
|
if (rc == WAIT_FAILED) |
|
throw WaitFailed(ThreadType()); |
|
|
|
_rep.count++; |
|
} |
|
|
|
void Mutex::try_lock() | void Mutex::try_lock() |
{ | { |
PEGASUS_DEBUG_ASSERT(_magic); | PEGASUS_DEBUG_ASSERT(_magic); |
|
|
| |
if (rc == WAIT_FAILED) | if (rc == WAIT_FAILED) |
throw WaitFailed(ThreadType()); | throw WaitFailed(ThreadType()); |
|
|
_rep.count++; |
|
} | } |
| |
void Mutex::timed_lock(Uint32 milliseconds) | void Mutex::timed_lock(Uint32 milliseconds) |
|
|
| |
if (rc == WAIT_FAILED) | if (rc == WAIT_FAILED) |
throw WaitFailed(ThreadType()); | throw WaitFailed(ThreadType()); |
|
|
_rep.count++; |
|
} |
|
|
|
void Mutex::unlock() |
|
{ |
|
PEGASUS_DEBUG_ASSERT(_magic); |
|
|
|
Threads::clear(ThreadType()); |
|
_rep.count--; |
|
ReleaseMutex(_rep.handle); |
|
} | } |
| |
#endif /* PEGASUS_HAVE_WINDOWS_THREADS */ | #endif /* PEGASUS_HAVE_WINDOWS_THREADS */ |