Multiple-reader, single-writer locks. Used to protect shared resources which
may be concurrently read, but only sequentially written.
All functions are exception safe. Throwing asynchronous exceptions will not
compromise the internal state of an RWLock. This means it is perfectly safe
to kill a thread that is blocking on, for example, acquireRead.
A convenience function wich first acquires read access and then performs the
computation. When the computation terminates, whether normally or by raising an
exception, the read lock is released.
A non-blocking withRead. First tries to acquire the lock. If that fails,
Nothing is returned. If it succeeds, the computation is performed. When the
computation terminates, whether normally or by raising an exception, the lock is
released and Just the result of the computation is returned.
Blocks if another thread has acquired either read or write access. If
acquireWrite terminates without throwing an exception the state of the
RWLock will be "write".
A convenience function wich first acquires write access and then performs
the computation. When the computation terminates, whether normally or by raising
an exception, the write lock is released.
A non-blocking withWrite. First tries to acquire the lock. If that fails,
Nothing is returned. If it succeeds, the computation is performed. When the
computation terminates, whether normally or by raising an exception, the lock is
released and Just the result of the computation is returned.