Class FileLockExecutor
- java.lang.Object
-
- com.sodius.oslc.server.concurrent.lock.FileLockExecutor
-
- All Implemented Interfaces:
LockExecutor
,Executor
public class FileLockExecutor extends Object implements LockExecutor
An executor that uses file locking to ensure runnable instances are executed sequentially.- Since:
- 3.5.0
-
-
Constructor Summary
Constructors Constructor Description FileLockExecutor(File file)
Creates an executor locking on the specified file.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description <V> V
execute(Callable<V> command)
Executes the given task and returns its computed result, with the guarantee no other task for the same lock can run concurrently.-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface com.sodius.oslc.server.concurrent.lock.LockExecutor
execute
-
-
-
-
Constructor Detail
-
FileLockExecutor
public FileLockExecutor(File file)
Creates an executor locking on the specified file.- Parameters:
file
- the file to lock to ensure non concurrent executions.
-
-
Method Detail
-
execute
public <V> V execute(Callable<V> command) throws Exception
Description copied from interface:LockExecutor
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.
- Specified by:
execute
in interfaceLockExecutor
- Type Parameters:
V
- the result type of methodcall
- Parameters:
command
- 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.
-
-