#include <ncbimtx.hpp>
Collaboration diagram for CRWLock:

Read/Write lock related data and methods.
Allows multiple readers or single writer with recursive locks. R-after-W is considered to be a recursive Write-lock. W-after-R is not allowed.
NOTE: When _DEBUG is not defined, does not always detect W-after-R correctly, so that deadlock may happen. Test your application in _DEBUG mode first!
Definition at line 910 of file ncbimtx.hpp.
Public Types | |
| typedef int | TFlags |
| binary OR of EFlags | |
| typedef CReadLockGuard | TReadLockGuard |
| Define Read Lock Guard. | |
| typedef CWriteLockGuard | TWriteLockGuard |
| Define Write Lock Guard. | |
| enum | EFlags { fFavorWriters = 0x1 } |
| Flags (passed at construction time) for fine-tuning lock behavior. More... | |
Public Member Functions | |
| CRWLock (TFlags flags=0) | |
| Constructor. | |
| ~CRWLock (void) | |
| Destructor. | |
| void | ReadLock (void) |
| Read lock. | |
| void | WriteLock (void) |
| Write lock. | |
| bool | TryReadLock (void) |
| Try read lock. | |
| bool | TryWriteLock (void) |
| Try write lock. | |
| void | Unlock (void) |
| Release the RW-lock. | |
Private Types | |
| enum | EInternalFlags { fTrackReaders = 0x40000000 } |
Private Member Functions | |
| bool | x_MayAcquireForReading (CThreadSystemID self_id) |
| CRWLock (const CRWLock &) | |
| Private copy constructor to disallow initialization. | |
| CRWLock & | operator= (const CRWLock &) |
| Private assignment operator to disallow assignment. | |
Private Attributes | |
| TFlags | m_Flags |
| Configuration flags. | |
| auto_ptr< CInternalRWLock > | m_RW |
| Platform-dependent RW-lock data. | |
| volatile CThreadSystemID | m_Owner |
| Writer ID, one of the readers ID. | |
| volatile int | m_Count |
| Number of readers (if >0) or writers (if <0). | |
| volatile unsigned int | m_WaitingWriters |
| Number of writers waiting; zero if not keeping track. | |
| vector< CThreadSystemID > | m_Readers |
| List of all readers or writers for debugging. | |
|
|
binary OR of EFlags
Definition at line 919 of file ncbimtx.hpp. |
|
|
Define Read Lock Guard.
Definition at line 928 of file ncbimtx.hpp. |
|
|
Define Write Lock Guard.
Definition at line 931 of file ncbimtx.hpp. |
|
|
Flags (passed at construction time) for fine-tuning lock behavior.
Definition at line 914 of file ncbimtx.hpp. |
|
|
Definition at line 965 of file ncbimtx.hpp. |
|
|
Constructor.
Definition at line 581 of file ncbimtx.cpp. References fFavorWriters, fTrackReaders, m_Flags, and m_Readers. |
|
|
Destructor.
Definition at line 600 of file ncbimtx.cpp. |
|
|
Private copy constructor to disallow initialization.
|
|
|
Private assignment operator to disallow assignment.
|
|
|
Read lock. Acquire the R-lock. If W-lock is already acquired by another thread, then wait until it is released. Definition at line 651 of file ncbimtx.cpp. References CThreadSystemID::GetCurrent(), CThreadSystemID::Is(), m_Count, m_Owner, m_RW, TRUE, x_MayAcquireForReading(), and xncbi_Validate. Referenced by CProjectConstPrx::CProjectConstPrx(), CQueueConstIterator::CQueueConstIterator(), CQueueIterator::CQueueIterator(), CWorkerNodeAffinityGuard::CWorkerNodeAffinityGuard(), CWorkspaceConstPrx::CWorkspaceConstPrx(), IRegistry::ReadLock(), and s_LOCK_Handler(). |
|
|
Try read lock. Try to acquire R-lock and return immediately.
Definition at line 732 of file ncbimtx.cpp. References CThreadSystemID::GetCurrent(), CThreadSystemID::IsNot(), m_Count, m_Owner, m_RW, and x_MayAcquireForReading(). Referenced by s_LOCK_Handler(). |
|
|
Try write lock. Try to acquire W-lock and return immediately.
Definition at line 869 of file ncbimtx.cpp. References CThreadSystemID::GetCurrent(), CThreadSystemID::IsNot(), m_Count, m_Owner, and m_RW. Referenced by s_LOCK_Handler(). |
|
|
Release the RW-lock.
Definition at line 920 of file ncbimtx.cpp. References _ASSERT, CThreadSystemID::GetCurrent(), CThreadSystemID::Is(), m_Count, m_Flags, m_Owner, m_Readers, m_RW, m_WaitingWriters, and xncbi_Validate. Referenced by s_LOCK_Handler(), IRegistry::Unlock(), CProjectConstPrx::~CProjectConstPrx(), CQueueConstIterator::~CQueueConstIterator(), CQueueIterator::~CQueueIterator(), CQueueWorkerNodeListGuard::~CQueueWorkerNodeListGuard(), CWorkerNodeAffinityGuard::~CWorkerNodeAffinityGuard(), and CWorkspaceConstPrx::~CWorkspaceConstPrx(). |
|
|
Write lock. Acquire the W-lock. If R-lock or W-lock is already acquired by another thread, then wait until it is released. Definition at line 776 of file ncbimtx.cpp. References CThreadSystemID::GetCurrent(), CThreadSystemID::Is(), m_Count, m_Owner, and m_RW. Referenced by CProjectPrx::CProjectPrx(), CQueueWorkerNodeListGuard::CQueueWorkerNodeListGuard(), s_LOCK_Handler(), and IRegistry::WriteLock(). |
|
|
Definition at line 605 of file ncbimtx.cpp. References _ASSERT, fFavorWriters, CThreadSystemID::GetCurrent(), m_Count, m_Flags, and m_Readers. Referenced by ReadLock(), and TryReadLock(). |
|
|
Number of readers (if >0) or writers (if <0).
Definition at line 976 of file ncbimtx.hpp. Referenced by ReadLock(), TryReadLock(), TryWriteLock(), Unlock(), WriteLock(), and x_MayAcquireForReading(). |
|
|
Configuration flags.
Definition at line 970 of file ncbimtx.hpp. Referenced by CRWLock(), Unlock(), and x_MayAcquireForReading(). |
|
|
Writer ID, one of the readers ID.
Definition at line 974 of file ncbimtx.hpp. Referenced by ReadLock(), TryReadLock(), TryWriteLock(), Unlock(), and WriteLock(). |
|
|
List of all readers or writers for debugging.
Definition at line 982 of file ncbimtx.hpp. Referenced by CRWLock(), Unlock(), and x_MayAcquireForReading(). |
|
|
Platform-dependent RW-lock data.
Definition at line 972 of file ncbimtx.hpp. Referenced by ReadLock(), TryReadLock(), TryWriteLock(), Unlock(), and WriteLock(). |
|
|
Number of writers waiting; zero if not keeping track.
Definition at line 979 of file ncbimtx.hpp. Referenced by Unlock(). |
1.4.6
Modified on Mon Dec 07 16:23:54 2009 by modify_doxy.py rev. 173732