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>
public class LazyFutureTask<V extends @Nullable Object> extends FutureTask<V>
Future implementation that can be used when a task should be executed only lazily at the first timeget()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 callingget()and not on the thread callingExecutorService.submit(Callable).Important: Calling
get(long, TimeUnit)is not supported and will always throwUnsupportedOperationException.Canceling this future works as expected.
-
-
Constructor Summary
Constructors Constructor Description LazyFutureTask(Runnable pRunnable, V pResult)LazyFutureTask(Callable<V> pCallable)
-
Method Summary
All Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description Vget()Vget(long pTimeout, TimeUnit pUnit)Deprecated.Unsupported operation.voidrun()-
Methods inherited from class java.util.concurrent.FutureTask
cancel, done, isCancelled, isDone, runAndReset, set, setException, toString
-
-
-
-
Method Detail
-
run
public void run()
- Specified by:
runin interfaceRunnable- Specified by:
runin interfaceRunnableFuture<V extends @Nullable Object>- Overrides:
runin classFutureTask<V extends @Nullable Object>
-
get
public V get() throws InterruptedException, ExecutionException
- Specified by:
getin interfaceFuture<V extends @Nullable Object>- Overrides:
getin classFutureTask<V extends @Nullable Object>- Throws:
InterruptedExceptionExecutionException
-
get
@Deprecated public V get(long pTimeout, TimeUnit pUnit)
Deprecated.Unsupported operation.- Specified by:
getin interfaceFuture<V extends @Nullable Object>- Overrides:
getin classFutureTask<V extends @Nullable Object>- Throws:
UnsupportedOperationException- Always
-
-