|
Mixes for Privacy and Anonymity in the Internet
|
From this class other classes could be derived, which need some kind from "locking" in memory. More...
Public Member Functions | |
| CALockAble () | |
| virtual | ~CALockAble () |
| SINT32 | lock () |
| Locks the lockable object by threadsafe incrementing a reference counter. | |
| SINT32 | unlock () |
| Unlocks the lockable object by threadsafe decrementing a reference counter. | |
Protected Member Functions | |
| SINT32 | waitForDestroy () |
| If called checks if the reference counter equals zero. | |
Private Attributes | |
| CAConditionVariable | m_ConVar |
| A conditional variable, which would be signaled if the rerference counter reaches zero. | |
| UINT32 | m_nLockCount |
| The reference counter. | |
From this class other classes could be derived, which need some kind from "locking" in memory.
Imagine for instance that thread t1 creates an object o of class c and uses it. During that a second thread t2 destroies o by calling delete o. Clearly this would be desasterous. To solve this problem cc should be derived from CALockAble. Than t1 calls o.lock() before using o and o.unlock() if t1 finsihed using o. If t2 calls delete o between the lock() / unlock() calls, it would block until all references of o are unlocked. Probablly this class is usefull for other tings, too...
References m_nLockCount.
| virtual CALockAble::~CALockAble | ( | ) | [virtual] |
Locks the lockable object by threadsafe incrementing a reference counter.
| E_SUCCESS |
References E_SUCCESS, CAMutex::lock(), m_ConVar, m_nLockCount, and CAMutex::unlock().
Referenced by CAMiddleMixChannelList::getInToOut(), CAMiddleMixChannelList::getOutToIn_intern_without_lock(), and CAFirstMixA::loop().
Unlocks the lockable object by threadsafe decrementing a reference counter.
The counter would never become less than zero. Every thread, which waits in waitForDestroy() will be signaled.
| E_SUCCESS |
References E_SUCCESS, CAMutex::lock(), m_ConVar, m_nLockCount, CAConditionVariable::signal(), and CAMutex::unlock().
Referenced by mm_loopReadFromMixAfter(), and mm_loopReadFromMixBefore().
| SINT32 CALockAble::waitForDestroy | ( | ) | [protected] |
If called checks if the reference counter equals zero.
If the reference counter is greater than zero, the call blocks.
| E_SUCCESS |
References E_SUCCESS, CAMutex::lock(), m_ConVar, m_nLockCount, CAMutex::unlock(), and CAConditionVariable::wait().
Referenced by CASymCipher::~CASymCipher().
CAConditionVariable CALockAble::m_ConVar [private] |
A conditional variable, which would be signaled if the rerference counter reaches zero.
Referenced by lock(), unlock(), and waitForDestroy().
UINT32 CALockAble::m_nLockCount [private] |
The reference counter.
Referenced by CALockAble(), lock(), unlock(), and waitForDestroy().
1.7.6.1