R - the result type of the computation.public class Tasklet<R>
extends java.lang.Object
implements java.lang.Runnable, java.util.function.BiFunction<R,java.lang.Throwable,R>
A Tasklet wraps a user-provided Callable and manages its execution context.
Unlike standard FutureTask, a Tasklet is designed to:
qid).SecondaryLoop.ProgressDisplayI and parent relationships.For off-EDT tasks, this class uses a specific CompletableFuture pattern.
The result future (returned to the caller) is chained to a trigger future via
CompletableFuture.handleAsync(BiFunction, java.util.concurrent.Executor).
Calling spawn() completes the trigger, which signals the ForkJoinPool to pick up
this Tasklet (via the apply(R, java.lang.Throwable) method) and execute the actual logic.
| Modifier and Type | Method and Description |
|---|---|
R |
apply(R input,
java.lang.Throwable exception)
Entry point for off-EDT execution via
CompletableFuture.handleAsync(java.util.function.BiFunction<? super T, java.lang.Throwable, ? extends U>). |
static ProgressDisplayI |
currentProgressDisplay()
Retrieves the
ProgressDisplayI associated with the current task. |
void |
run()
The core execution logic.
|
static void |
setCurrentProgressDisplay(ProgressDisplayI progressDisplay)
Associates a
ProgressDisplayI with the currently running Tasklet. |
java.lang.String |
toString() |
public R apply(R input, java.lang.Throwable exception)
CompletableFuture.handleAsync(java.util.function.BiFunction<? super T, java.lang.Throwable, ? extends U>).
This acts as an adapter between the CompletableFuture API and our run() method.
It waits for the result (which is computed inside run()) to ensure the future chain completes.
public void run()
This method:
result future.run in interface java.lang.Runnablepublic static void setCurrentProgressDisplay(ProgressDisplayI progressDisplay)
ProgressDisplayI with the currently running Tasklet.
This allows progress updates to be routed to the correct UI component associated with this task.progressDisplay - the progress display to set.public static ProgressDisplayI currentProgressDisplay()
ProgressDisplayI associated with the current task.null.public java.lang.String toString()
toString in class java.lang.ObjectCopyright © 2000-2026 OAshi S.à r.l. All Rights Reserved.