Interface StepElement

  • All Superinterfaces:
    ChartElement<StepDefinition>

    public interface StepElement
    extends ChartElement<StepDefinition>
    This is the control interface for step elements. It represents the 5 different operations that can be performed on a step:
    • Activate - Start execution
    • Deactivate - A subsequent transition has activated. The step may choose to stop immediately, or finish its work.
    • Pause - The step should stop work, expecting to resume later
    • Resume - The step should continue from where pause left off
    • Cancel - The chart or step has been cancelled, the step should stop execution and clean up.

    It is important to understand how chart threading works: Each chart (or branch of a parallel block) has a single control thread. Messages are passed on this thread, and are translated into events that end up calling these functions. In other words, all of these functions are called on the control thread. Therefore, blocking in these functions will block the processing of additional messages on the control thread. This may be desirable, but might also have unintended consequences. For example, if an implementation blocks in activateStep, there is no way that a pauseStep or cancelStep can be called.

    To handle this, the implementation can use its own thread management, or take advantage of the StepController passed in to activate and resume. The StepController provides an execute() function that will execute a task in a new thread, without blocking the control thread, while still not allowing the chart flow to continue until the work is finished.

    • Method Detail

      • activateStep

        default void activateStep​(StepController context)
        Activate this step. This method should block until activation is complete.
      • deactivateStep

        default void deactivateStep()
        Deactivate this step. This method should block until deactivation is complete.
      • pauseStep

        default void pauseStep()
        Pause this step. This method should block until pausing is complete.
      • resumeStep

        default void resumeStep​(StepController context)
        Resume this step. This method should block until resuming is complete.
      • cancelStep

        default void cancelStep()
        Cancel the step. This method can block until cancellation is complete.