vrecko
virtual reality framework
|
#include <MTLock.h>
Public Member Functions | |
MTReadWriteLock () | |
~MTReadWriteLock () | |
bool | lockRead (DWORD Timeout=INFINITE) |
bool | lockWrite (DWORD Timeout=INFINITE) |
void | unlockRead (DWORD Timeout=INFINITE) |
void | unlockWrite (DWORD Timeout=INFINITE) |
Protected Attributes | |
HANDLE | m_Access |
int | m_Readers |
HANDLE | m_WriterMutex |
HANDLE | m_CanRead |
HANDLE | m_CanWrite |
ReadWrite locks are from the following article by Ivan Krivyakov: http://www.codeguru.com/cpp/w-p/system/misc/article.php/c5679
MTReadWriteLock is a read/write mutex.
Any number of readers can acquire the mutex for read (LockRead()). Only single writer can acquire the mutex for write (LockWrite()). No other writers or readers can hold the mutex while writer uses it.
MTReadWriteLock does not prefer neither writers nor readers. I.e. if both writers and readers are waiting for the lock, any of them can grab the lock when it is released by previous owner.
MTReadWriteLock is recursive, but not upgradable. This means that
if you have a read lock, you can safely acquire another read lock. if you have a read lock, you CANNOT acquire a write lock (deadlock!).
if you have a write lock, you can safely acquire another write lock. if you have a write lock, you CANNOT acquire a read lock (deadlock!).
vrecko::MTReadWriteLock::MTReadWriteLock | ( | ) |
vrecko::MTReadWriteLock::~MTReadWriteLock | ( | ) |
MTLOCK_IMP_EXP bool vrecko::MTReadWriteLock::lockRead | ( | DWORD | Timeout = INFINITE | ) |
MTLOCK_IMP_EXP bool vrecko::MTReadWriteLock::lockWrite | ( | DWORD | Timeout = INFINITE | ) |
MTLOCK_IMP_EXP void vrecko::MTReadWriteLock::unlockRead | ( | DWORD | Timeout = INFINITE | ) |
MTLOCK_IMP_EXP void vrecko::MTReadWriteLock::unlockWrite | ( | DWORD | Timeout = INFINITE | ) |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |