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)
Deprecated.
Since 9.4.0; Use
readLockedBoolean(BooleanSupplier)
instead |
double |
readLocked(DoubleSupplier aSupplier)
Deprecated.
Since 9.4.0; Use
readLockedDouble(DoubleSupplier)
instead |
int |
readLocked(IntSupplier aSupplier)
Deprecated.
Since 9.4.0; Use
readLockedInt(IntSupplier) instead |
long |
readLocked(LongSupplier aSupplier)
Deprecated.
Since 9.4.0; Use
readLockedLong(LongSupplier) instead |
void |
readLocked(Runnable aRunnable)
Execute the provided runnable in a read lock.
|
<T> T |
readLocked(Supplier<? extends T> aSupplier)
Deprecated.
Since 9.4.0; Use
readLockedGet(Supplier) instead |
boolean |
readLockedBoolean(BooleanSupplier aSupplier)
Execute the provided callable in a read lock.
|
double |
readLockedDouble(DoubleSupplier aSupplier)
Execute the provided callable in a read lock.
|
<T> T |
readLockedGet(Supplier<? extends T> aSupplier)
Execute the provided callable in a read lock.
|
<T,EXTYPE extends Exception> |
readLockedGetThrowing(IThrowingSupplier<? extends T,EXTYPE> aCallable)
Execute the provided callable in a read lock.
|
int |
readLockedInt(IntSupplier aSupplier)
Execute the provided callable in a read lock.
|
long |
readLockedLong(LongSupplier 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)
Deprecated.
Since 9.4.0; Use
readLockedGetThrowing(IThrowingSupplier) instead |
boolean |
writeLocked(BooleanSupplier aSupplier)
Deprecated.
Since 9.4.0; Use
writeLockedBoolean(BooleanSupplier)
instead |
double |
writeLocked(DoubleSupplier aSupplier)
Deprecated.
Since 9.4.0; Use
writeLockedDouble(DoubleSupplier)
instead |
int |
writeLocked(IntSupplier aSupplier)
Deprecated.
Since 9.4.0; Use
writeLockedInt(IntSupplier) instead |
long |
writeLocked(LongSupplier aSupplier)
Deprecated.
Since 9.4.0; Use
writeLockedLong(LongSupplier) instead |
void |
writeLocked(Runnable aRunnable)
Execute the provided runnable in a write lock.
|
<T> T |
writeLocked(Supplier<? extends T> aSupplier)
Deprecated.
Since 9.4.0; Use
writeLockedGet(Supplier) instead |
boolean |
writeLockedBoolean(BooleanSupplier aSupplier)
Execute the provided callable in a write lock.
|
double |
writeLockedDouble(DoubleSupplier aSupplier)
Execute the provided callable in a write lock.
|
<T> T |
writeLockedGet(Supplier<? extends T> aSupplier)
Execute the provided callable in a write lock.
|
<T,EXTYPE extends Exception> |
writeLockedGetThrowing(IThrowingSupplier<? extends T,EXTYPE> aCallable)
Execute the provided callable in a write lock.
|
int |
writeLockedInt(IntSupplier aSupplier)
Execute the provided callable in a write lock.
|
long |
writeLockedLong(LongSupplier 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)
Deprecated.
Since 9.4.0; Use
writeLockedGetThrowing(IThrowingSupplier) instead |
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 policy@Deprecated public <T> T readLocked(@Nonnull Supplier<? extends T> aSupplier)
readLockedGet(Supplier) insteadT - Return typeaSupplier - Callable to be executed. May not be null.null.public <T> T readLockedGet(@Nonnull Supplier<? extends T> aSupplier)
T - Return typeaSupplier - Callable to be executed. May not be null.null.public 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@Deprecated public <T,EXTYPE extends Exception> T readLockedThrowing(@Nonnull IThrowingSupplier<? extends T,EXTYPE> aCallable) throws EXTYPE extends Exception
readLockedGetThrowing(IThrowingSupplier) insteadT - 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 <T,EXTYPE extends Exception> T readLockedGetThrowing(@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 Exception@Deprecated public boolean readLocked(@Nonnull BooleanSupplier aSupplier)
readLockedBoolean(BooleanSupplier)
insteadaSupplier - Callable to be executed. May not be null.null.public boolean readLockedBoolean(@Nonnull BooleanSupplier aSupplier)
aSupplier - Callable to be executed. May not be null.null.@Deprecated public double readLocked(@Nonnull DoubleSupplier aSupplier)
readLockedDouble(DoubleSupplier)
insteadaSupplier - Callable to be executed. May not be null.null.public double readLockedDouble(@Nonnull DoubleSupplier aSupplier)
aSupplier - Callable to be executed. May not be null.null.@Deprecated public int readLocked(@Nonnull IntSupplier aSupplier)
readLockedInt(IntSupplier) insteadaSupplier - Callable to be executed. May not be null.null.public int readLockedInt(@Nonnull IntSupplier aSupplier)
aSupplier - Callable to be executed. May not be null.null.@Deprecated public long readLocked(@Nonnull LongSupplier aSupplier)
readLockedLong(LongSupplier) insteadaSupplier - Callable to be executed. May not be null.null.public long readLockedLong(@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 Exception@Deprecated public <T> T writeLocked(@Nonnull Supplier<? extends T> aSupplier)
writeLockedGet(Supplier) insteadT - Return typeaSupplier - Callable to be executed. May not be null.null.public <T> T writeLockedGet(@Nonnull Supplier<? extends T> aSupplier)
T - Return typeaSupplier - Callable to be executed. May not be null.null.@Deprecated public <T,EXTYPE extends Exception> T writeLockedThrowing(@Nonnull IThrowingSupplier<? extends T,EXTYPE> aCallable) throws EXTYPE extends Exception
writeLockedGetThrowing(IThrowingSupplier) insteadT - 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 <T,EXTYPE extends Exception> T writeLockedGetThrowing(@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 Exception@Deprecated public boolean writeLocked(@Nonnull BooleanSupplier aSupplier)
writeLockedBoolean(BooleanSupplier)
insteadaSupplier - Callable to be executed. May not be null.null.public boolean writeLockedBoolean(@Nonnull BooleanSupplier aSupplier)
aSupplier - Callable to be executed. May not be null.null.@Deprecated public double writeLocked(@Nonnull DoubleSupplier aSupplier)
writeLockedDouble(DoubleSupplier)
insteadaSupplier - Callable to be executed. May not be null.null.public double writeLockedDouble(@Nonnull DoubleSupplier aSupplier)
aSupplier - Callable to be executed. May not be null.null.@Deprecated public int writeLocked(@Nonnull IntSupplier aSupplier)
writeLockedInt(IntSupplier) insteadaSupplier - Callable to be executed. May not be null.null.public int writeLockedInt(@Nonnull IntSupplier aSupplier)
aSupplier - Callable to be executed. May not be null.null.@Deprecated public long writeLocked(@Nonnull LongSupplier aSupplier)
writeLockedLong(LongSupplier) insteadaSupplier - Callable to be executed. May not be null.null.public long writeLockedLong(@Nonnull LongSupplier aSupplier)
aSupplier - Callable to be executed. May not be null.null.Copyright © 2014–2020 Philip Helger. All rights reserved.