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.