|
org.codehaus.gpars | |||||||
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 java.util.concurrent.locks.ReentrantReadWriteLock
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 }*
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 | |
---|---|
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(long), java.util.concurrent.locks.ReentrantReadWriteLock#wait(), java.util.concurrent.locks.ReentrantReadWriteLock#wait(long, int), 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() |
Methods inherited from class java.lang.Object | |
---|---|
java.lang.Object#wait(long), java.lang.Object#wait(), java.lang.Object#wait(long, int), 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() |
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 held
public void withWriteLock(groovy.lang.Closure cl)
cl
- The closure to perform with the write lock held
Copyright © 2008–2010 Václav Pech. All Rights Reserved.