version 1.12, 2008/09/09 17:38:27
|
version 1.13, 2008/09/16 18:37:03
|
|
|
#include "Time.h" | #include "Time.h" |
#include "PegasusAssert.h" | #include "PegasusAssert.h" |
#include "Threads.h" | #include "Threads.h" |
|
#include "Exception.h" |
|
#include "System.h" |
| |
PEGASUS_NAMESPACE_BEGIN | PEGASUS_NAMESPACE_BEGIN |
| |
|
|
| |
void ReadWriteSem::waitRead() | void ReadWriteSem::waitRead() |
{ | { |
if (pthread_rwlock_rdlock(&_rwlock.rwlock) != 0) |
int r = pthread_rwlock_rdlock(&_rwlock.rwlock); |
|
|
|
if (r != 0) |
|
{ |
|
if (r != -1) |
{ | { |
throw WaitFailed(Threads::self()); |
// Special behavior for Single UNIX Specification, Version 3 |
|
errno = r; |
|
} |
|
|
|
throw Exception(MessageLoaderParms( |
|
"Common.InternalException.READ_LOCK_FAILED", |
|
"Failed to acquire read lock: $0", |
|
PEGASUS_SYSTEM_ERRORMSG_NLS)); |
} | } |
} | } |
| |
void ReadWriteSem::waitWrite() | void ReadWriteSem::waitWrite() |
{ | { |
if (pthread_rwlock_wrlock(&_rwlock.rwlock) != 0) |
int r = pthread_rwlock_wrlock(&_rwlock.rwlock); |
|
|
|
if (r != 0) |
|
{ |
|
if (r != -1) |
{ | { |
throw WaitFailed(Threads::self()); |
// Special behavior for Single UNIX Specification, Version 3 |
|
errno = r; |
|
} |
|
|
|
throw Exception(MessageLoaderParms( |
|
"Common.InternalException.WRITE_LOCK_FAILED", |
|
"Failed to acquire write lock: $0", |
|
PEGASUS_SYSTEM_ERRORMSG_NLS)); |
} | } |
} | } |
| |
|
|
{ | { |
_rwlock._internal_lock.lock(); | _rwlock._internal_lock.lock(); |
} | } |
catch (IPCException &) |
catch (...) |
{ | { |
PEGASUS_ASSERT(0); | PEGASUS_ASSERT(0); |
} | } |