diff --git a/UML/timeout.png b/UML/timeout.png new file mode 100644 index 0000000..44ed31b Binary files /dev/null and b/UML/timeout.png differ diff --git a/UML/timeout.puml b/UML/timeout.puml new file mode 100644 index 0000000..728d94b --- /dev/null +++ b/UML/timeout.puml @@ -0,0 +1,62 @@ +@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 \ No newline at end of file diff --git a/readme.md b/readme.md index 082b72e..c6745ec 100644 --- a/readme.md +++ b/readme.md @@ -8,6 +8,9 @@ # Time Algorithm +
+ Code puml (maybe it's displayed) + ```plantuml @startuml @@ -37,9 +40,15 @@ endif @enduml ``` + +
+ +# Sequence Diagrams +## Timeout + # Tests ## Test 1