Wrapper for readers/writer locks. More...
#include <RW_Mutex.h>

Public Member Functions | |
| ACE_RW_Mutex (int type=USYNC_THREAD, const ACE_TCHAR *name=0, void *arg=0) | |
| Initialize a readers/writer lock. | |
| ~ACE_RW_Mutex (void) | |
| Implicitly destroy a readers/writer lock. | |
| int | remove (void) |
| int | acquire_read (void) |
| Acquire a read lock, but block if a writer hold the lock. | |
| int | acquire_write (void) |
| int | tryacquire_read (void) |
| int | tryacquire_write (void) |
| Conditionally acquire a write lock (i.e., won't block). | |
| int | tryacquire_write_upgrade (void) |
| int | acquire (void) |
| int | tryacquire (void) |
| int | release (void) |
| Unlock a readers/writer lock. | |
| const ACE_rwlock_t & | lock (void) const |
| Return the underlying lock. | |
| void | dump (void) const |
| Dump the state of an object. | |
Public Attributes | |
| ACE_ALLOC_HOOK_DECLARE | |
| Declare the dynamic allocation hooks. | |
Protected Attributes | |
| ACE_rwlock_t | lock_ |
| Readers/writer lock. | |
| bool | removed_ |
Private Member Functions | |
| void | operator= (const ACE_RW_Mutex &) |
| ACE_RW_Mutex (const ACE_RW_Mutex &) | |
Wrapper for readers/writer locks.
These are most useful for applications that have many more parallel readers than writers...
Definition at line 41 of file RW_Mutex.h.
| ACE_RW_Mutex::ACE_RW_Mutex | ( | int | type = USYNC_THREAD, |
|
| const ACE_TCHAR * | name = 0, |
|||
| void * | arg = 0 | |||
| ) |
Initialize a readers/writer lock.
| ACE_RW_Mutex::~ACE_RW_Mutex | ( | void | ) |
Implicitly destroy a readers/writer lock.
| ACE_RW_Mutex::ACE_RW_Mutex | ( | const ACE_RW_Mutex & | ) | [private] |
| int ACE_RW_Mutex::acquire | ( | void | ) |
Note, for interface uniformity with other synchronization wrappers we include the <acquire> method. This is implemented as a write-lock to safe...
Definition at line 42 of file RW_Mutex.inl.
00043 { 00044 // ACE_TRACE ("ACE_RW_Mutex::acquire"); 00045 return ACE_OS::rw_wrlock (&this->lock_); 00046 }
| int ACE_RW_Mutex::acquire_read | ( | void | ) |
Acquire a read lock, but block if a writer hold the lock.
Definition at line 28 of file RW_Mutex.inl.
00029 { 00030 // ACE_TRACE ("ACE_RW_Mutex::acquire_read"); 00031 return ACE_OS::rw_rdlock (&this->lock_); 00032 }
| int ACE_RW_Mutex::acquire_write | ( | void | ) |
Acquire a write lock, but block if any readers or a writer hold the lock.
Definition at line 35 of file RW_Mutex.inl.
00036 { 00037 // ACE_TRACE ("ACE_RW_Mutex::acquire_write"); 00038 return ACE_OS::rw_wrlock (&this->lock_); 00039 }
| void ACE_RW_Mutex::dump | ( | void | ) | const |
Dump the state of an object.
Reimplemented in ACE_RW_Thread_Mutex.
| const ACE_rwlock_t & ACE_RW_Mutex::lock | ( | void | ) | const |
Return the underlying lock.
Definition at line 8 of file RW_Mutex.inl.
00009 { 00010 // ACE_TRACE ("ACE_RW_Mutex::lock"); 00011 return this->lock_; 00012 }
| void ACE_RW_Mutex::operator= | ( | const ACE_RW_Mutex & | ) | [private] |
| int ACE_RW_Mutex::release | ( | void | ) |
Unlock a readers/writer lock.
Definition at line 77 of file RW_Mutex.inl.
00078 { 00079 // ACE_TRACE ("ACE_RW_Mutex::release"); 00080 return ACE_OS::rw_unlock (&this->lock_); 00081 }
| int ACE_RW_Mutex::remove | ( | void | ) |
Explicitly destroy a readers/writer lock. Note that only one thread should call this method since it doesn't protect against race conditions.
Definition at line 15 of file RW_Mutex.inl.
00016 { 00017 // ACE_TRACE ("ACE_RW_Mutex::remove"); 00018 int result = 0; 00019 if (!this->removed_) 00020 { 00021 this->removed_ = true; 00022 result = ACE_OS::rwlock_destroy (&this->lock_); 00023 } 00024 return result; 00025 }
| int ACE_RW_Mutex::tryacquire | ( | void | ) |
Note, for interface uniformity with other synchronization wrappers we include the <tryacquire> method. This is implemented as a write-lock to be safe... Returns -1 on failure. If we "failed" because someone else already had the lock, errno is set to EBUSY.
Definition at line 70 of file RW_Mutex.inl.
00071 { 00072 // ACE_TRACE ("ACE_RW_Mutex::tryacquire"); 00073 return this->tryacquire_write (); 00074 }
| int ACE_RW_Mutex::tryacquire_read | ( | void | ) |
Conditionally acquire a read lock (i.e., won't block). Returns -1 on failure. If we "failed" because someone else already had the lock, errno is set to EBUSY.
Definition at line 49 of file RW_Mutex.inl.
00050 { 00051 // ACE_TRACE ("ACE_RW_Mutex::tryacquire_read"); 00052 return ACE_OS::rw_tryrdlock (&this->lock_); 00053 }
| int ACE_RW_Mutex::tryacquire_write | ( | void | ) |
Conditionally acquire a write lock (i.e., won't block).
Definition at line 56 of file RW_Mutex.inl.
00057 { 00058 // ACE_TRACE ("ACE_RW_Mutex::tryacquire_write"); 00059 return ACE_OS::rw_trywrlock (&this->lock_); 00060 }
| int ACE_RW_Mutex::tryacquire_write_upgrade | ( | void | ) |
Conditionally upgrade a read lock to a write lock. This only works if there are no other readers present, in which case the method returns 0. Otherwise, the method returns -1 and sets errno to EBUSY. Note that the caller of this method *must* already possess this lock as a read lock (but this condition is not checked by the current implementation).
Reimplemented in ACE_RW_Thread_Mutex.
Definition at line 63 of file RW_Mutex.inl.
00064 { 00065 // ACE_TRACE ("ACE_RW_Mutex::tryacquire_write_upgrade"); 00066 return ACE_OS::rw_trywrlock_upgrade (&this->lock_); 00067 }
Declare the dynamic allocation hooks.
Reimplemented in ACE_RW_Thread_Mutex.
Definition at line 112 of file RW_Mutex.h.
ACE_rwlock_t ACE_RW_Mutex::lock_ [protected] |
Readers/writer lock.
Definition at line 116 of file RW_Mutex.h.
bool ACE_RW_Mutex::removed_ [protected] |
Keeps track of whether <remove> has been called yet to avoid multiple <remove> calls, e.g., explicitly and implicitly in the destructor. This flag isn't protected by a lock, so make sure that you don't have multiple threads simultaneously calling <remove> on the same object, which is a bad idea anyway...
Definition at line 123 of file RW_Mutex.h.
1.6.1