Read Write Lock
A ReadWrite lock allows multiple readers to read a value and only one writer to update it. A read lock cannot be obtained until write lock is released. A write lock cannot be obtained until current readers don't release read lock.
Examples
val lock = ReadWriteLock()
// read from multiple threads simultaneously.
lock.acquireReadLock() // call from as many threads
// perform read ....
lock.releaseReadLock()
// to protect writes
lock.acquireWriteLock() // only one thread will get lock, others will be blocked.
// perform write ....
lock.releaseWriteLock() // next thread will now unblock.
class ReadWriteLock
Content copied to clipboard
class ReadWriteLock
Content copied to clipboard
Constructors
Functions
acquireReadLock
Link copied to clipboard
fun acquireReadLock()
Content copied to clipboard
fun acquireReadLock()
Content copied to clipboard
acquireWriteLock
Link copied to clipboard
fun acquireWriteLock()
Content copied to clipboard
fun acquireWriteLock()
Content copied to clipboard
destroy
Link copied to clipboard
equals
Link copied to clipboard
releaseReadLock
Link copied to clipboard
fun releaseReadLock()
Content copied to clipboard
fun releaseReadLock()
Content copied to clipboard
releaseWriteLock
Link copied to clipboard
fun releaseWriteLock()
Content copied to clipboard
fun releaseWriteLock()
Content copied to clipboard