|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object java.util.concurrent.locks.ReentrantReadWriteLock groovyx.gpars.util.EnhancedRWLock
public class EnhancedRWLock
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 }*
Nested Class Summary |
---|
Nested classes/interfaces inherited from class java.util.concurrent.locks.ReentrantReadWriteLock |
---|
java.util.concurrent.locks.ReentrantReadWriteLock.ReadLock, java.util.concurrent.locks.ReentrantReadWriteLock.WriteLock |
Field Summary | |
---|---|
private static long |
serialVersionUID
|
Constructor Summary | |
---|---|
EnhancedRWLock()
|
|
EnhancedRWLock(boolean fair)
|
Method Summary | |
---|---|
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 java.util.concurrent.locks.ReentrantReadWriteLock |
---|
getOwner, getQueuedReaderThreads, getQueuedThreads, getQueuedWriterThreads, getQueueLength, getReadHoldCount, getReadLockCount, getWaitingThreads, getWaitQueueLength, getWriteHoldCount, hasQueuedThread, hasQueuedThreads, hasWaiters, isFair, isWriteLocked, isWriteLockedByCurrentThread, readLock, toString, writeLock |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
private static final long serialVersionUID
Constructor Detail |
---|
public EnhancedRWLock()
public EnhancedRWLock(boolean fair)
Method Detail |
---|
public void withReadLock(groovy.lang.Closure cl)
cl
- The closure to perform with the read lock heldpublic void withWriteLock(groovy.lang.Closure cl)
cl
- The closure to perform with the write lock held
|
Copyright © 2008–2012 Václav Pech. All Rights Reserved. | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |