java.lang.Object
org.jhotdraw8.fxbase.concurrent.FXWorker
FXWorker provides convenience methods for
executing CheckedRunnable objects on a- Author:
- Werner Randelshofer
-
Method Summary
Modifier and TypeMethodDescriptionstatic CompletableFuture<Void> run(Executor executor, CheckedRunnable runnable) Calls the runnable on the executor thread.static CompletableFuture<Void> run(CheckedRunnable runnable) Calls the runnable on a new Thread.static <T> CompletableFuture<T> Calls the supplier on a thread of the common fork join pool.static <T> CompletableFuture<T> Calls the supplier on the executor thread.static <T> CompletableWorker<T> work(Executor executor, CheckedFunction<WorkState<T>, T> supplier, WorkState<T> workState) Calls the supplier on the executor thread.
-
Method Details
-
run
Calls the runnable on a new Thread. The completion stage is completed on the FX Application Thread.- Parameters:
runnable- the runnable- Returns:
- the CompletableFuture
-
run
Calls the runnable on the executor thread. The completion stage is completed on the FX Application Thread.- Parameters:
executor- the executor, if null then a new thread is createdrunnable- the runnable- Returns:
- the CompletableFuture
-
supply
Calls the supplier on a thread of the common fork join pool. The completion stage is completed on the FX Application Thread.- Type Parameters:
T- the value type- Parameters:
supplier- the supplier- Returns:
- the CompletableFuture
-
supply
Calls the supplier on the executor thread. TheCompletableFutureis completed on the FX Application Thread.- Type Parameters:
T- the value type- Parameters:
executor- the executorsupplier- the supplier- Returns:
- the
CompletableFuture
-
work
public static <T> CompletableWorker<T> work(Executor executor, CheckedFunction<WorkState<T>, T> supplier, WorkState<T> workState) Calls the supplier on the executor thread. TheCompletableWorkeris completed on the FX Application Thread.- Type Parameters:
T- the value type- Parameters:
executor- the executorsupplier- the supplier- Returns:
- the
CompletableWorker
-