Class PausableFutureStepWork

java.lang.Object
com.inductiveautomation.sfc.api.util.PausableFutureStepWork
All Implemented Interfaces:
Consumer<StepController>

public class PausableFutureStepWork extends Object implements 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 Details

    • PausableFutureStepWork

      public PausableFutureStepWork(CompletableFuture<?> chartFuture)
    • PausableFutureStepWork

      public PausableFutureStepWork(CompletableFuture<?> chartFuture, Runnable exitTask)
      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

      public CompletableFuture<Void> rearm()
      Resets this work for a new execution episode (used on resume). Installs a fresh exitSignal. 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

      public Runnable getExitTask()
      Returns the exit task supplied at construction.
      Returns:
      the task to run when the work exits, or null if none was supplied.
    • accept

      @Deprecated(since="8.3.8", forRemoval=true) public void accept(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. The controller now drives completion off the per-episode exit signal (see rearm()) via StepController.executeUntilComplete(com.inductiveautomation.sfc.api.util.PausableFutureStepWork), so this is no longer invoked. Retained as a no-op only to preserve the Consumer contract.
      No-op retained only to preserve the Consumer contract.
      Specified by:
      accept in interface Consumer<StepController>