My Project
|
multiple shared readers and multiple exclusive writers it favors writers over readers. More...
#include <BlockReadWriteLock.h>
Public Member Functions | |
void | BeginRead () |
recursive calls is possible and will be regarded as new readers at minimum cost. More... | |
void | EndRead () |
void | BeginWrite (size_t nWriterThreadId=0) |
void | EndWrite () |
size_t | GetCurrentThreadId () |
bool | HasWaitingWriters () |
this function just check writer count WITHOUT using a lock. More... | |
bool | HasWaitingWritersAndSingleReader () |
bool | HasWriterLock () |
bool | IsCurrentThreadHasWriterLock () |
whether the current thread is holding the writer lock. More... | |
uint32 | GetWritelockRecursiveDepth () const |
multiple shared readers and multiple exclusive writers it favors writers over readers.
All lock functions are recursive of its kind. Within write lock, there can be read lock; but within read lock, there can NOT be write lock. Upgrade to write lock is not supported yet, but is possible.
This is synchronization object between main thread, the light calculation and the block IO thread. This is a special read/write lock class tailored for the situation in block rendering. it favors writers over readers. I have referred to Doug Lea's WriterPreferenceReadWriteLock class
void ParaEngine::BlockReadWriteLock::BeginRead | ( | ) |
recursive calls is possible and will be regarded as new readers at minimum cost.
bool ParaEngine::BlockReadWriteLock::HasWaitingWriters | ( | ) |
this function just check writer count WITHOUT using a lock.
it is fast to call, but never rely on the result. The reader can use this function as a hint of whether writer is hungry now, and release lock for it.
bool ParaEngine::BlockReadWriteLock::IsCurrentThreadHasWriterLock | ( | ) |
whether the current thread is holding the writer lock.