The following tables list the members exposed by SimpleReadWriteLocking.
Name | Description | |
---|---|---|
SimpleReadWriteLocking Constructor | Overloaded. |
Name | Description | |
---|---|---|
WriteVersion | Changes every time a write lock is aquired. If WriteVersion == 0, no write locks have been issued. |
Name | Description | |
---|---|---|
Dispose | Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources. | |
Read | Overloaded. Returns a reader lock that can be elevated to a write lock | |
ReleaseRead | Releases a read lock | |
ReleaseWrite | Releases a writer lock | |
TryRead | Returns true if the lock was successfully obtained within the timeout specified | |
TryWrite | Returns true if the lock was successfully obtained within the timeout specified | |
Write | Overloaded. Returns a read and write lock |
Name | Description | |
---|---|---|
WaitForExclusive | This is the only real work to be done, once we've acquired the write lock we have to wait for all readers to complete. If/when that happens we can then own the write lock. The case where this does not take place is when a thread that already owns the lock calls us to lock again. In this case we can just return success and ignore the outstanding read requests. The major problem with this approach is that if function A() does a read-lock and calls function B() which does a write lock, this will fail. So the solution is to either use the upgradeable version (see the derived class UpgradableReadWriteLocking) and upgrade, or to start with a write lock in function A(). |