Package org.openrefine.process
Interface ProgressingFuture<T>
-
- Type Parameters:
T
- the type of value to be computed.
- All Superinterfaces:
Future<T>
,com.google.common.util.concurrent.ListenableFuture<T>
- All Known Implementing Classes:
CompletedFuture
,FailingFuture
,ProgressingFutureWrapper
public interface ProgressingFuture<T> extends com.google.common.util.concurrent.ListenableFuture<T>
Represents an asynchronous task which returns a result. In addition to the methods offered byFuture
, this interface adds the ability to pause and resume the underlying process, as well as retrieve its progress, expressed as a percentage.
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description int
getProgress()
boolean
isPaused()
void
onProgress(ProgressReporter reporter)
Registers a callback to be called every time the progress of this task changes.void
pause()
Pauses the process that is computing the value to be returned in this future.void
resume()
Resumes the process that is computing the value to be returned in this future.boolean
supportsProgress()
-
-
-
Method Detail
-
pause
void pause()
Pauses the process that is computing the value to be returned in this future. If this process is not running, this action has no effect.
-
resume
void resume()
Resumes 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.
-
isPaused
boolean isPaused()
- Returns:
- whether the process is currently paused
-
supportsProgress
boolean supportsProgress()
- 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
int getProgress()
- 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
void onProgress(ProgressReporter reporter)
Registers 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.- Parameters:
reporter
- the callback to call.
-
-