class Concurrent::ReadWriteLock

Ruby read-write lock implementation

Allows any number of concurrent readers, but only one concurrent writer (And if the “write” lock is taken, any readers who come along will have to wait)

If readers are already active when a writer comes along, the writer will wait for all the readers to finish before going ahead. Any additional readers that come when the writer is already waiting, will also wait (so writers are not starved).

This implementation is based on ‘java.util.concurrent.ReentrantReadWriteLock`.

@example

lock = Concurrent::ReadWriteLock.new
lock.with_read_lock  { data.retrieve }
lock.with_write_lock { data.modify! }

@note Do not try to acquire the write lock while already holding a read lock

**or** try to acquire the write lock while you already have it.
This will lead to deadlock

@see docs.oracle.com/javase/7/docs/api/java/util/concurrent/locks/ReentrantReadWriteLock.html java.util.concurrent.ReentrantReadWriteLock