UML 状态图:完成转换

UML state charts: completion transitions

在具有 运行-to-completion 模型的 UML 状态图的上下文中,"completion transitions" 是如何处理的?

  1. 状态的完成在事件队列的开头插入一个 "completion event",因此 "completion transition" 仅在状态机显式步进时执行,或者
  2. 状态的完成会立即触发 "completion transition"(可能还有后续的 "completion transitions"),因此状态机可能会为每个显式步进执行多个步骤。

这两种情况都表明,一个状态的不受保护 "completion transition" 有效地使任何其他定义的转换(无论是事件触发的还是受保护的)变得多余。

我理解正确吗?

答案更接近 #2 ('completion of a state immediately triggers the "completion transition"'),但您随后提到 "multiple steps for each explicit stepping." 我不明白您的意思。

UML 2.5 规范在第 14.2.38.3 节中说:

A special kind of Transition is a completion Transition, which has an implicit trigger. The event that enables this trigger is called a completion event and it signifies that all Behaviors associated with the source State of the completion Transition have completed execution. In case of simple States, a completion event is generated when the associated entry and doActivity Behaviors have completed executing. If no such Behaviors are defined, the completion event is generated upon entry into the State.

该规范继续描述了如何为复合或子机状态生成完成事件。既然你问的是这个更简单的案例,我就跳过它。

该规范还说“完成事件具有调度优先级。也就是说,它们在任何未决事件发生之前被调度 事件池。”因此,不会调度其他定义的转换。