public class SimpleReadWriteLock extends ReentrantReadWriteLock
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.ReentrantReadWriteLock.ReadLock, ReentrantReadWriteLock.WriteLock| 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 |
|---|---|
boolean |
readLocked(BooleanSupplier aSupplier)
Execute the provided callable in a read lock.
|
double |
readLocked(DoubleSupplier aSupplier)
Execute the provided callable in a read lock.
|
int |
readLocked(IntSupplier aSupplier)
Execute the provided callable in a read lock.
|
long |
readLocked(LongSupplier aSupplier)
Execute the provided callable in a read lock.
|
void |
readLocked(Runnable aRunnable)
Execute the provided runnable in a read lock.
|
<T> T |
readLocked(Supplier<? extends T> aSupplier)
Execute the provided callable in a read lock.
|
<EXTYPE extends Exception> |
readLockedThrowing(IThrowingRunnable<EXTYPE> aRunnable)
Execute the provided runnable in a read lock.
|
<T,EXTYPE extends Exception> |
readLockedThrowing(IThrowingSupplier<? extends T,EXTYPE> aCallable)
Execute the provided callable in a read lock.
|
boolean |
writeLocked(BooleanSupplier aSupplier)
Execute the provided callable in a write lock.
|
double |
writeLocked(DoubleSupplier aSupplier)
Execute the provided callable in a write lock.
|
int |
writeLocked(IntSupplier aSupplier)
Execute the provided callable in a write lock.
|
long |
writeLocked(LongSupplier aSupplier)
Execute the provided callable in a write lock.
|
void |
writeLocked(Runnable aRunnable)
Execute the provided runnable in a write lock.
|
<T> T |
writeLocked(Supplier<? extends T> aSupplier)
Execute the provided callable in a write lock.
|
<EXTYPE extends Exception> |
writeLockedThrowing(IThrowingRunnable<EXTYPE> aRunnable)
Execute the provided runnable in a write lock.
|
<T,EXTYPE extends Exception> |
writeLockedThrowing(IThrowingSupplier<? extends T,EXTYPE> aCallable)
Execute the provided callable in a write lock.
|
getOwner, getQueuedReaderThreads, getQueuedThreads, getQueuedWriterThreads, getQueueLength, getReadHoldCount, getReadLockCount, getWaitingThreads, getWaitQueueLength, getWriteHoldCount, hasQueuedThread, hasQueuedThreads, hasWaiters, isFair, isWriteLocked, isWriteLockedByCurrentThread, readLock, toString, writeLockpublic SimpleReadWriteLock()
ReentrantReadWriteLockpublic SimpleReadWriteLock(boolean bFair)
ReentrantReadWriteLock with the provided
fairnessbFair - true if this lock should use a fair ordering policypublic 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 Exceptionpublic <T> T readLocked(@Nonnull Supplier<? extends T> aSupplier)
T - Return typeaSupplier - Callable to be executed. May not be null.null.public <T,EXTYPE extends Exception> T readLockedThrowing(@Nonnull IThrowingSupplier<? extends 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 boolean readLocked(@Nonnull BooleanSupplier aSupplier)
aSupplier - Callable to be executed. May not be null.null.public double readLocked(@Nonnull DoubleSupplier aSupplier)
aSupplier - Callable to be executed. May not be null.null.public int readLocked(@Nonnull IntSupplier aSupplier)
aSupplier - Callable to be executed. May not be null.null.public long readLocked(@Nonnull LongSupplier aSupplier)
aSupplier - Callable to be executed. May not be null.null.public 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 Exceptionpublic <T> T writeLocked(@Nonnull Supplier<? extends T> aSupplier)
T - Return typeaSupplier - Callable to be executed. May not be null.null.public <T,EXTYPE extends Exception> T writeLockedThrowing(@Nonnull IThrowingSupplier<? extends 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 boolean writeLocked(@Nonnull BooleanSupplier aSupplier)
aSupplier - Callable to be executed. May not be null.null.public double writeLocked(@Nonnull DoubleSupplier aSupplier)
aSupplier - Callable to be executed. May not be null.null.public int writeLocked(@Nonnull IntSupplier aSupplier)
aSupplier - Callable to be executed. May not be null.null.public long writeLocked(@Nonnull LongSupplier aSupplier)
aSupplier - Callable to be executed. May not be null.null.Copyright © 2014–2017 Philip Helger. All rights reserved.