Transition sort

Transitions are sorted before they are executed. In yasmine transitions have priorities and the transitions with higher priority are scheduled first for execution.

The sorting algorithm is based on the nesting level of the least common ancestor of the source and target of the transition. A higher nesting level means a higher priority. Transitions with the same priority are fired in arbitrary order.

yasmine does this in order to avoid conflicts in certain situation. This is beyond the scope of the UML specification.

Example 1

images/download/attachments/3408277/transition_sort_1.png

We consider the following:

  • 'T1' the transition fired by the event 'E1' emanating from 'Simple state 1' and targeting 'Simple state 2'.

  • 'T2' the transition fired by the event 'E1' emanating from 'Simple state 3' and targeting 'Simple state 4'.

The transition ‘T2’ has a higher priority than the transition ‘T1’ because the nesting level 1 of ‘Composite state 1’ (which is the least common ancestor of ‘Simple state 3’ and ‘Simple state 4’) is higher than the nesting level 0 of the root state (which is the common ancestor of ‘Simple state 1’ and ‘Simple state 2').

Example 2

images/download/attachments/3408277/transition_sort_2.png

We consider the following:

  • 'T1' the transition fired by the event 'E1' emanating from 'Simple state 1' and targeting 'Simple state 2'.

  • 'T2' the transition fired by the event 'E1' emanating from 'Simple state 3' and targeting 'Simple state 4'.

  • 'T3' the transition fired by the event 'E1' emanating from 'Simple state 5' and targeting 'Simple state 6'.

The order of the transitions will be: 'T2', 'T1' and then 'T3'. This is because the nesting level of the least common ancestor of the source and target of the three transitions are:

  • 1 for ‘T1’

  • 2 for ‘T2

  • 0 for ‘T3’