#include <ReadWriteLock.h>
Public Member Functions | |
CReadWriteLock () | |
Construct the lock object, unlocked. | |
CSyncObject & | GetWriteLock () |
Return a #CSyncObject corresponding to the write lock for this object. | |
CSyncObject & | GetReadLock () |
Return a #CSyncObject corresponding to the read lock for this object. |
The lock is recursive, but not upgradable. This is handled by an additional reader being counted for each read lock recursion, and a recursion count for each write recursion.
Gives priority to writers (a waiting writer is released before any waiting readers) to prevent writer starvation.
Note that the events are mainly advisory: they do not guarantee freedom to read or write, but merely signal that it is likely. Thus the lock code spins to check the state again. Occasionally, events may be left set in error, which is ok due to the spin.
|
Return a #CSyncObject corresponding to the read lock for this object.
|
|
Return a #CSyncObject corresponding to the write lock for this object.
|