public class SimpleReadWriteLock extends Object implements ReadWriteLock, Serializable
ReentrantReadWriteLock that allows for
easy usage with Java 8 :) See readLocked(Runnable) and
writeLocked(Runnable) method. For throwing versions see
readLockedThrowing(IThrowingRunnable) and
writeLockedThrowing(IThrowingRunnable). Also methods for callables
are available.| Constructor and Description |
|---|
SimpleReadWriteLock()
Default constructor creating a default
ReentrantReadWriteLock |
SimpleReadWriteLock(boolean bFair)
Constructor creating a
ReentrantReadWriteLock with the provided
fairness |
| Modifier and Type | Method and Description |
|---|---|
Lock |
readLock() |
<T> T |
readLocked(INonThrowingCallable<T> aCallable)
Execute the provided callable in a read lock.
|
void |
readLocked(Runnable aRunnable)
Execute the provided runnable in a read lock.
|
<T,EXTYPE extends Exception> |
readLockedThrowing(IThrowingCallable<T,EXTYPE> aCallable)
Execute the provided callable in a read lock.
|
<EXTYPE extends Exception> |
readLockedThrowing(IThrowingRunnable<EXTYPE> aRunnable)
Execute the provided runnable in a read lock.
|
Lock |
writeLock() |
<T> T |
writeLocked(INonThrowingCallable<T> aCallable)
Execute the provided callable in a write lock.
|
void |
writeLocked(Runnable aRunnable)
Execute the provided runnable in a write lock.
|
<T,EXTYPE extends Exception> |
writeLockedThrowing(IThrowingCallable<T,EXTYPE> aCallable)
Execute the provided callable in a write lock.
|
<EXTYPE extends Exception> |
writeLockedThrowing(IThrowingRunnable<EXTYPE> aRunnable)
Execute the provided runnable in a write lock.
|
public SimpleReadWriteLock()
ReentrantReadWriteLockpublic SimpleReadWriteLock(boolean bFair)
ReentrantReadWriteLock with the provided
fairnessbFair - true if this lock should use a fair ordering policy@Nonnull public Lock readLock()
readLock in interface ReadWriteLock@Nonnull public Lock writeLock()
writeLock in interface ReadWriteLockpublic void readLocked(@Nonnull Runnable aRunnable)
aRunnable - Runnable to be executed. May not be null.public <EXTYPE extends Exception> void readLockedThrowing(@Nonnull IThrowingRunnable<EXTYPE> aRunnable) throws EXTYPE extends Exception
EXTYPE - Exception type to be thrownaRunnable - Runnable to be executed. May not be null.EXTYPE - If the callable throws the exceptionEXTYPE extends Exception@Nullable public <T> T readLocked(@Nonnull INonThrowingCallable<T> aCallable)
T - Return typeaCallable - Callable to be executed. May not be null.null.@Nullable public <T,EXTYPE extends Exception> T readLockedThrowing(@Nonnull IThrowingCallable<T,EXTYPE> aCallable) throws EXTYPE extends Exception
T - Return typeEXTYPE - Exception type to be thrownaCallable - Callable to be executed. May not be null.null.EXTYPE - If the callable throws the exceptionEXTYPE extends Exceptionpublic void writeLocked(@Nonnull Runnable aRunnable)
aRunnable - Runnable to be executed. May not be null.public <EXTYPE extends Exception> void writeLockedThrowing(@Nonnull IThrowingRunnable<EXTYPE> aRunnable) throws EXTYPE extends Exception
EXTYPE - Exception type to be thrownaRunnable - Runnable to be executed. May not be null.EXTYPE - If the runnable throws the exceptionEXTYPE extends Exception@Nullable public <T> T writeLocked(@Nonnull INonThrowingCallable<T> aCallable)
T - Return typeaCallable - Callable to be executed. May not be null.null.@Nullable public <T,EXTYPE extends Exception> T writeLockedThrowing(@Nonnull IThrowingCallable<T,EXTYPE> aCallable) throws EXTYPE extends Exception
T - Return typeEXTYPE - Exception type to be thrownaCallable - Callable to be executed. May not be null.null.EXTYPE - If the callable throws the exceptionEXTYPE extends ExceptionCopyright © 2014–2015 Philip Helger. All rights reserved.