62 lines
1.1 KiB
Plaintext
62 lines
1.1 KiB
Plaintext
|
@startuml
|
||
|
|
||
|
participant "Behavior::StateMachine" as sm
|
||
|
participant Dispatcher as d
|
||
|
participant TimeoutManager as tm
|
||
|
entity "Event::Timeout" as t
|
||
|
queue "TimeoutManager::timeouts_" as timeouts
|
||
|
|
||
|
autoactivate off
|
||
|
|||
|
||
|
|||
|
||
|
== Schedule timeout ==
|
||
|
|||
|
||
|
sm -> sm++ : scheduleTimeout
|
||
|
sm -> d ++: getDispatcher
|
||
|
d --> sm --: dispatcher
|
||
|
sm -> d --++ : scheduleTimeout
|
||
|
d -> tm ++: getTimeoutManager
|
||
|
tm --> d --: timeoutManager
|
||
|
d -> tm --++ : scheduleTimeout
|
||
|
tm -> t ** : new
|
||
|
t --> tm
|
||
|
tm -> timeouts --++: insert
|
||
|
|
||
|
|||
|
||
|
|||
|
||
|
== Decrement timeout (and dispatch) ==
|
||
|
|||
|
||
|
loop every tickInterval
|
||
|
?->> tm ++: tick
|
||
|
tm -> timeouts : getFront
|
||
|
timeouts -> t ++
|
||
|
t --> timeouts
|
||
|
timeouts --> tm : timeout
|
||
|
tm -> t --: decrement
|
||
|
end
|
||
|
|||
|
||
|
note left t
|
||
|
When timeout is 0,
|
||
|
dispatch event
|
||
|
end note
|
||
|
t -> timeouts : pop
|
||
|
deactivate timeouts
|
||
|
t ->? --: pushEvent
|
||
|
|
||
|
|||
|
||
|
|||
|
||
|
== Unschedule timeout ==
|
||
|
|||
|
||
|
sm -> sm++ : unscheduleTimeout
|
||
|
sm -> d ++: getDispatcher
|
||
|
d --> sm --: dispatcher
|
||
|
sm -> d --++ : unscheduleTimeout
|
||
|
d -> tm ++: getTimeoutManager
|
||
|
tm --> d --: timeoutManager
|
||
|
d -> tm --++ : unscheduleTimeout
|
||
|
tm -> timeouts --: erase
|
||
|
timeouts -> t !!
|
||
|
|
||
|
|
||
|
|
||
|
@enduml
|