R
- type of result to be computed by a given taskP
- type of progress indicator (to be) associated with a given taskpublic class ProgressRunner<R,P extends ProgressIndicator>
extends java.lang.Object
A builder-like API for running tasks with ProgressIndicator
.
Main goals of this implementation is to:
Create a new ProgressRunner
object with a constructor, providing it with a task to execute.
Specify execution thread and progress indicator via respective calls withProgress(P1)
and onThread(com.intellij.openapi.progress.impl.ProgressRunner.ThreadToUse)
, respectively.
Submit task and retrieve result as a CompletableFuture
via submit()
or synchronously as data via submitAndGet()
Modifier and Type | Class and Description |
---|---|
static class |
ProgressRunner.ThreadToUse |
Constructor and Description |
---|
ProgressRunner(java.util.function.Function<? super ProgressIndicator,R> computation)
Creates new
ProgressRunner builder instance dedicated to calculating computation . |
ProgressRunner(java.lang.Runnable computation)
Creates new
ProgressRunner builder instance dedicated to calculating computation . |
ProgressRunner(Task task)
Creates new
ProgressRunner builder instance dedicated to calculating task . |
Modifier and Type | Method and Description |
---|---|
static boolean |
isCanceled(java.util.concurrent.Future<? extends ProgressIndicator> progressFuture) |
ProgressRunner<R,P> |
modal() |
ProgressRunner<R,P> |
onThread(ProgressRunner.ThreadToUse thread)
Specifies thread which should execute computation.
|
java.util.concurrent.CompletableFuture<ProgressResult<R>> |
submit()
Executes computation with the previously specified environment asynchronously, or synchronously
if
sync() was called previously. |
ProgressResult<R> |
submitAndGet()
Executes computation with the previously specified environment synchronously.
|
ProgressRunner<R,P> |
sync() |
static java.lang.Throwable |
unwrap(java.lang.Throwable exception) |
<P1 extends ProgressIndicator> |
withProgress(java.util.concurrent.CompletableFuture<P1> progressIndicatorFuture)
Specifies an asynchronous computation which will be used to obtain progress indicator to be associated with computation under progress.
|
<P1 extends ProgressIndicator> |
withProgress(P1 progressIndicator)
Specifies a progress indicator to be associated with computation under progress.
|
public ProgressRunner(java.lang.Runnable computation)
ProgressRunner
builder instance dedicated to calculating computation
.
Does not start computation.computation
- runnable to be executed under progresspublic ProgressRunner(Task task)
ProgressRunner
builder instance dedicated to calculating task
.
Does not start computation.task
- task to be executed under progresspublic ProgressRunner(java.util.function.Function<? super ProgressIndicator,R> computation)
ProgressRunner
builder instance dedicated to calculating computation
.
Does not start computation.computation
- runnable to be executed under progresspublic ProgressRunner<R,P> sync()
public ProgressRunner<R,P> modal()
public ProgressRunner<R,P> onThread(ProgressRunner.ThreadToUse thread)
ProgressRunner.ThreadToUse.POOLED
and ProgressRunner.ThreadToUse.WRITE
.thread
- thread to execute computationpublic <P1 extends ProgressIndicator> ProgressRunner<R,P1> withProgress(P1 progressIndicator)
progressIndicator
- progress indicator instancepublic <P1 extends ProgressIndicator> ProgressRunner<R,P1> withProgress(java.util.concurrent.CompletableFuture<P1> progressIndicatorFuture)
progressIndicatorFuture
- future with progress indicatorpublic ProgressResult<R> submitAndGet()
ProgressResult
data class representing the result of computationpublic java.util.concurrent.CompletableFuture<ProgressResult<R>> submit()
sync()
was called previously.ProgressResult
data classpublic static boolean isCanceled(java.util.concurrent.Future<? extends ProgressIndicator> progressFuture)
public static java.lang.Throwable unwrap(java.lang.Throwable exception)