Extends ReentrantReadWriteLock with handy withReadLock(Closure) and withWriteLock(Closure) methods to safely lock and unlock the lock for the passed-in closure. Use: def extendedLock = new ExtendedRWLock() extendedLock.withReadLock() {* //read lock locked here }*
Modifiers | Name | Description |
---|---|---|
private static long |
serialVersionUID |
Constructor and description |
---|
EnhancedRWLock
() |
EnhancedRWLock
(boolean fair) |
Type | Name and description |
---|---|
void |
withReadLock(groovy.lang.Closure cl) Performs the passed-in closure with the read lock locked and unlocks the read lock automatically after the closure finishes. |
void |
withWriteLock(groovy.lang.Closure cl) Performs the passed-in closure with the write lock locked and unlocks the write lock automatically after the closure finishes. |
Methods inherited from class | Name |
---|---|
class java.util.concurrent.locks.ReentrantReadWriteLock |
java.util.concurrent.locks.ReentrantReadWriteLock#toString(), java.util.concurrent.locks.ReentrantReadWriteLock#getQueueLength(), java.util.concurrent.locks.ReentrantReadWriteLock#getWaitQueueLength(java.util.concurrent.locks.Condition), java.util.concurrent.locks.ReentrantReadWriteLock#hasQueuedThread(java.lang.Thread), java.util.concurrent.locks.ReentrantReadWriteLock#hasQueuedThreads(), java.util.concurrent.locks.ReentrantReadWriteLock#hasWaiters(java.util.concurrent.locks.Condition), java.util.concurrent.locks.ReentrantReadWriteLock#isFair(), java.util.concurrent.locks.ReentrantReadWriteLock#readLock(), java.util.concurrent.locks.ReentrantReadWriteLock#readLock(), java.util.concurrent.locks.ReentrantReadWriteLock#writeLock(), java.util.concurrent.locks.ReentrantReadWriteLock#writeLock(), java.util.concurrent.locks.ReentrantReadWriteLock#getReadHoldCount(), java.util.concurrent.locks.ReentrantReadWriteLock#getReadLockCount(), java.util.concurrent.locks.ReentrantReadWriteLock#getWriteHoldCount(), java.util.concurrent.locks.ReentrantReadWriteLock#isWriteLocked(), java.util.concurrent.locks.ReentrantReadWriteLock#isWriteLockedByCurrentThread(), java.util.concurrent.locks.ReentrantReadWriteLock#wait(), java.util.concurrent.locks.ReentrantReadWriteLock#wait(long, int), java.util.concurrent.locks.ReentrantReadWriteLock#wait(long), java.util.concurrent.locks.ReentrantReadWriteLock#equals(java.lang.Object), java.util.concurrent.locks.ReentrantReadWriteLock#hashCode(), java.util.concurrent.locks.ReentrantReadWriteLock#getClass(), java.util.concurrent.locks.ReentrantReadWriteLock#notify(), java.util.concurrent.locks.ReentrantReadWriteLock#notifyAll() |
class java.lang.Object |
java.lang.Object#wait(), java.lang.Object#wait(long, int), java.lang.Object#wait(long), java.lang.Object#equals(java.lang.Object), java.lang.Object#toString(), java.lang.Object#hashCode(), java.lang.Object#getClass(), java.lang.Object#notify(), java.lang.Object#notifyAll() |
Performs the passed-in closure with the read lock locked and unlocks the read lock automatically after the closure finishes.
cl
- The closure to perform with the read lock heldPerforms the passed-in closure with the write lock locked and unlocks the write lock automatically after the closure finishes.
cl
- The closure to perform with the write lock heldCopyright © 2008–2014 Václav Pech. All Rights Reserved.