Class PausableFutureStepWork
java.lang.Object
com.inductiveautomation.sfc.api.util.PausableFutureStepWork
- All Implemented Interfaces:
Consumer<StepController>
A helper class to be used with
StepController.executeUntilComplete(com.inductiveautomation.sfc.api.util.PausableFutureStepWork), takes a
CompletableFuture, and will block step progression until the future has completed. However, the
work can also be "paused", in which case the step is allowed to exit. This is commonly used for
step pause, and then the same object is re-submitted to the StepController upon resume (see
rearm()).
Additionally, a runnable can be passed in that will be called each time the work exits (on completion, and on pause).
Unlike the original implementation, this no longer parks a dedicated native thread waiting on
a monitor. Instead, an exitSignal CompletableFuture fires when the work should
exit (the backing future completed, or the step was paused), and the StepController
registers a completion callback on it. A step that is merely "waiting for a future" therefore
holds no thread.
-
Constructor Summary
ConstructorsConstructorDescriptionPausableFutureStepWork(CompletableFuture<?> chartFuture) PausableFutureStepWork(CompletableFuture<?> chartFuture, Runnable exitTask) Exits (allowing the step to proceed) once the provided future is complete, unless paused. -
Method Summary
Modifier and TypeMethodDescriptionvoidaccept(StepController controller) Deprecated, for removal: This API element is subject to removal in a future version.legacy entry point for the old parked-thread model, where the controller ran this on a dedicated thread that blocked on a monitor.voidfinish()Returns the exit task supplied at construction.voidpause()rearm()Resets this work for a new execution episode (used on resume).
-
Constructor Details
-
PausableFutureStepWork
-
PausableFutureStepWork
Exits (allowing the step to proceed) once the provided future is complete, unless paused. If exitTask is not null, each time the work exits (pause or completion), the function will be called.
-
-
Method Details
-
finish
public void finish() -
pause
public void pause() -
rearm
Resets this work for a new execution episode (used on resume). Installs a freshexitSignal. If the backing future already finished while we were paused, the new signal is completed immediately so the resumed step exits right away (matching the legacy "if already finished, finish right away on re-execute" behavior).- Returns:
- the freshly installed exit signal for the new episode.
-
getExitTask
Returns the exit task supplied at construction.- Returns:
- the task to run when the work exits, or
nullif none was supplied.
-
accept
Deprecated, for removal: This API element is subject to removal in a future version.legacy entry point for the old parked-thread model, where the controller ran this on a dedicated thread that blocked on a monitor. The controller now drives completion off the per-episode exit signal (seerearm()) viaStepController.executeUntilComplete(com.inductiveautomation.sfc.api.util.PausableFutureStepWork), so this is no longer invoked. Retained as a no-op only to preserve theConsumercontract.No-op retained only to preserve theConsumercontract.- Specified by:
acceptin interfaceConsumer<StepController>
-