Package org.sosy_lab.common
Class LazyFutureTask<V extends @Nullable Object>
java.lang.Object
java.util.concurrent.FutureTask<V>
org.sosy_lab.common.LazyFutureTask<V>
- All Implemented Interfaces:
Runnable,Future<V>,RunnableFuture<V>
Future implementation that can be used when a task should be executed only lazily at the first
time
get() is called. I.e., it is not guaranteed that the task is run at all, but it is
called at most once.
Execution of the task happens in the caller's thread, a little bit similar to the use of
MoreExecutors.newDirectExecutorService(), however, it
is executed on the thread calling get() and not on the thread calling ExecutorService.submit(Callable).
Important: Calling get(long, TimeUnit) is not supported and will always throw UnsupportedOperationException.
Canceling this future works as expected.
-
Constructor Summary
ConstructorsConstructorDescriptionLazyFutureTask(Runnable pRunnable, V pResult) LazyFutureTask(Callable<V> pCallable) -
Method Summary
Methods inherited from class java.util.concurrent.FutureTask
cancel, done, isCancelled, isDone, runAndReset, set, setException, toString
-
Constructor Details
-
LazyFutureTask
-
LazyFutureTask
-
-
Method Details
-
run
public void run()- Specified by:
runin interfaceRunnable- Specified by:
runin interfaceRunnableFuture<V extends @Nullable Object>- Overrides:
runin classFutureTask<V extends @Nullable Object>
-
get
- Specified by:
getin interfaceFuture<V extends @Nullable Object>- Overrides:
getin classFutureTask<V extends @Nullable Object>- Throws:
InterruptedExceptionExecutionException
-
get
Deprecated.Unsupported operation.- Specified by:
getin interfaceFuture<V extends @Nullable Object>- Overrides:
getin classFutureTask<V extends @Nullable Object>- Throws:
UnsupportedOperationException- Always
-