Class ProgressingFutureWrapper<T>
- java.lang.Object
-
- org.openrefine.runners.local.pll.util.ProgressingFutureWrapper<T>
-
- All Implemented Interfaces:
com.google.common.util.concurrent.ListenableFuture<T>,Future<T>,ProgressingFuture<T>
public class ProgressingFutureWrapper<T> extends Object implements ProgressingFuture<T>
A future which supports pausing and progress reporting, assuming the underlying future was built on a task that relies on the suppliedTaskSignallingobject to periodically check for pause and report progress.
-
-
Constructor Summary
Constructors Constructor Description ProgressingFutureWrapper(com.google.common.util.concurrent.ListenableFuture<T> future, TaskSignalling taskSignalling, boolean supportsProgress)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddListener(Runnable listener, Executor executor)booleancancel(boolean b)Tget()Tget(long l, TimeUnit timeUnit)intgetProgress()booleanisCancelled()booleanisDone()booleanisPaused()voidonProgress(ProgressReporter reporter)Registers a callback to be called every time the progress of this task changes.voidpause()Pauses the process that is computing the value to be returned in this future.voidresume()Resumes the process that is computing the value to be returned in this future.booleansupportsProgress()
-
-
-
Constructor Detail
-
ProgressingFutureWrapper
public ProgressingFutureWrapper(com.google.common.util.concurrent.ListenableFuture<T> future, TaskSignalling taskSignalling, boolean supportsProgress)
-
-
Method Detail
-
pause
public void pause()
Description copied from interface:ProgressingFuturePauses the process that is computing the value to be returned in this future. If this process is not running, this action has no effect.- Specified by:
pausein interfaceProgressingFuture<T>
-
resume
public void resume()
Description copied from interface:ProgressingFutureResumes the process that is computing the value to be returned in this future. If this process had not been paused before, this action has no effect.- Specified by:
resumein interfaceProgressingFuture<T>
-
isPaused
public boolean isPaused()
- Specified by:
isPausedin interfaceProgressingFuture<T>- Returns:
- whether the process is currently paused
-
supportsProgress
public boolean supportsProgress()
- Specified by:
supportsProgressin interfaceProgressingFuture<T>- Returns:
- whether the underlying process supports reporting progress beyond a boolean status, that is to say whether it can be in progress states strictly between 0 and 100.
-
getProgress
public int getProgress()
- Specified by:
getProgressin interfaceProgressingFuture<T>- Returns:
- the current progress percentage of the task, between 0 and 100. If the task does not support reporting progress, this returns 0 until the task is successful, after which it returns 100. If the task results in an error, the progress might not reach 100.
-
onProgress
public void onProgress(ProgressReporter reporter)
Description copied from interface:ProgressingFutureRegisters a callback to be called every time the progress of this task changes. The callback will be called at least once, on registration, with the current value of the progress.- Specified by:
onProgressin interfaceProgressingFuture<T>- Parameters:
reporter- the callback to call.
-
isCancelled
public boolean isCancelled()
- Specified by:
isCancelledin interfaceFuture<T>
-
get
public T get() throws InterruptedException, ExecutionException
- Specified by:
getin interfaceFuture<T>- Throws:
InterruptedExceptionExecutionException
-
get
public T get(long l, TimeUnit timeUnit) throws InterruptedException, ExecutionException, TimeoutException
- Specified by:
getin interfaceFuture<T>- Throws:
InterruptedExceptionExecutionExceptionTimeoutException
-
-