Now the mystery transitions Stop,
Block and Delete are defined.
The reason why these transitions have no start state is
because they are taken no matter the current state. Well,
not exactly.
-
Stop: If a task is still alive ( in theSuspended,RunningorBlockedstate), then it must immediately transition to the stopping state. If a task is not alive (in the other three states), this transition is ignored because the task is no longer alive. -
Block: If a task is eitherSuspendedorRunning, then it transitions to theBlockedstate. Otherwise this request is ignored. -
Delete: If a task is in any state other thanDeleted, then it must transition to theDeletedstate.
SMC provides two ways to define default transitions:
the Default state and the
Default transtion.
Manual section 2
describes how Default state and
transition work. Go there to learn more about them.
Task.sm is updated with the default
Stop, Block and
Delete transition definitions:
The blockTask() and stopTask()
methods are added to the Task class:
There is one more improvement to the FSM that needs to be
made before we finish. Notice that the
Running state's transitions must stop the
slice timer. If a new transtion is added to
Running, the developer must remember to
include the stopSliceTimer() action. This is
a potential problem because a different developer
maintaining this FSM may not know about this. But there is
a solution to this.