Class FileLockExecutor
java.lang.Object
com.sodius.oslc.server.concurrent.lock.FileLockExecutor
- All Implemented Interfaces:
LockExecutor,Executor
An executor that uses file locking to ensure runnable instances are executed sequentially.
- Since:
- 3.5.0
-
Constructor Summary
ConstructorsConstructorDescriptionFileLockExecutor(File file) Creates an executor locking on the specified file. -
Method Summary
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface com.sodius.oslc.server.concurrent.lock.LockExecutor
execute
-
Constructor Details
-
FileLockExecutor
Creates an executor locking on the specified file.- Parameters:
file- the file to lock to ensure non concurrent executions.
-
-
Method Details
-
execute
Description copied from interface:LockExecutorExecutes 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:
executein 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 aCompletionExceptionif thetaskis eitherinterruptedor the timeout to acquire the lock expires.
-