Interface LockExecutor
-
- All Superinterfaces:
Executor
- All Known Implementing Classes:
AbstractLockExecutor
,FileLockExecutor
public interface LockExecutor extends Executor
An object that executes submittedRunnable
orCallable
tasks. Tasks are guaranteed to execute sequentially for the lock used when creating the executor instance.- Since:
- 3.5.0
- See Also:
LockExecutors.get(String)
-
-
Method Summary
All Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description default void
execute(Runnable task)
Executes the given task, with the guarantee no other task for the same lock can run concurrently.<V> V
execute(Callable<V> task)
Executes the given task and returns its computed result, with the guarantee no other task for the same lock can run concurrently.
-
-
-
Method Detail
-
execute
default void execute(Runnable task)
Executes the given task, with the guarantee no other task for the same lock can run concurrently.The task is expected to be very lightweight and short-running, so that it does't block for too long other concurrent requests.
- Specified by:
execute
in interfaceExecutor
- Throws:
CompletionException
- if thetask
is eitherinterrupted
or the timeout to acquire the lock expires.
-
execute
<V> V execute(Callable<V> task) throws Exception
Executes the given task and returns its computed result, with the guarantee no other task for the same lock can run concurrently.The task is expected to be very lightweight and short-running, so that it does't block for too long other concurrent requests.
- Type Parameters:
V
- the result type of methodcall
- Parameters:
task
- the runnable task- Returns:
- the computed result
- Throws:
Exception
- if unable to compute a result. The exception is aCompletionException
if thetask
is eitherinterrupted
or the timeout to acquire the lock expires.
-
-