public interface FunctionalLock extends Lock
Lock
interface to enable locking for the duration of a lambda or other
FunctionalInterface
invocation.Modifier and Type | Method and Description |
---|---|
default <RESULT_TYPE,EXCEPTION_TYPE extends Exception> |
computeLocked(FunctionalInterfaces.ThrowingSupplier<RESULT_TYPE,EXCEPTION_TYPE> supplier)
Acquire the lock, invoke
FunctionalInterfaces.ThrowingSupplier.get() while holding the lock, and release the lock before
returning the result. |
default <RESULT_TYPE,EXCEPTION_TYPE extends Exception> |
computeLockedInterruptibly(FunctionalInterfaces.ThrowingSupplier<RESULT_TYPE,EXCEPTION_TYPE> supplier)
Acquire the lock interruptibly, invoke
FunctionalInterfaces.ThrowingSupplier.get() while holding the lock, and release the
lock before returning the result. |
default <EXCEPTION_TYPE extends Exception> |
doLocked(FunctionalInterfaces.ThrowingRunnable<EXCEPTION_TYPE> runnable)
Acquire the lock, invoke
FunctionalInterfaces.ThrowingRunnable.run() while holding the lock, and release the lock before
returning. |
default <EXCEPTION_TYPE extends Exception> |
doLockedInterruptibly(FunctionalInterfaces.ThrowingRunnable<EXCEPTION_TYPE> runnable)
Acquire the lock interruptibly, invoke
FunctionalInterfaces.ThrowingRunnable.run() while holding the lock, and release the
lock before returning. |
lock, lockInterruptibly, newCondition, tryLock, tryLock, unlock
default <EXCEPTION_TYPE extends Exception> void doLocked(@NotNull FunctionalInterfaces.ThrowingRunnable<EXCEPTION_TYPE> runnable) throws EXCEPTION_TYPE extends Exception
FunctionalInterfaces.ThrowingRunnable.run()
while holding the lock, and release the lock before
returning.runnable
- The FunctionalInterfaces.ThrowingRunnable
to runEXCEPTION_TYPE
- If runnable
throws its declared exceptionEXCEPTION_TYPE extends Exception
default <EXCEPTION_TYPE extends Exception> void doLockedInterruptibly(@NotNull FunctionalInterfaces.ThrowingRunnable<EXCEPTION_TYPE> runnable) throws InterruptedException, EXCEPTION_TYPE extends Exception
FunctionalInterfaces.ThrowingRunnable.run()
while holding the lock, and release the
lock before returning.runnable
- The FunctionalInterfaces.ThrowingRunnable.run()
to runInterruptedException
- If the current thread was interrupted while waiting to acquire the lockEXCEPTION_TYPE
- If runnable
throws its declared exceptionEXCEPTION_TYPE extends Exception
default <RESULT_TYPE,EXCEPTION_TYPE extends Exception> RESULT_TYPE computeLocked(@NotNull FunctionalInterfaces.ThrowingSupplier<RESULT_TYPE,EXCEPTION_TYPE> supplier) throws EXCEPTION_TYPE extends Exception
FunctionalInterfaces.ThrowingSupplier.get()
while holding the lock, and release the lock before
returning the result.supplier
- The FunctionalInterfaces.ThrowingSupplier
to getsupplier
EXCEPTION_TYPE
- If supplier
throws its declared exceptionEXCEPTION_TYPE extends Exception
default <RESULT_TYPE,EXCEPTION_TYPE extends Exception> RESULT_TYPE computeLockedInterruptibly(@NotNull FunctionalInterfaces.ThrowingSupplier<RESULT_TYPE,EXCEPTION_TYPE> supplier) throws InterruptedException, EXCEPTION_TYPE extends Exception
FunctionalInterfaces.ThrowingSupplier.get()
while holding the lock, and release the
lock before returning the result.supplier
- The FunctionalInterfaces.ThrowingSupplier
to getsupplier
InterruptedException
- If the current thread was interrupted while waiting to acquire the lockEXCEPTION_TYPE
- If supplier
throws its declared exceptionEXCEPTION_TYPE extends Exception