-
Notifications
You must be signed in to change notification settings - Fork 9
/
sequence_chart.puml
152 lines (140 loc) · 3.79 KB
/
sequence_chart.puml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
@startuml
control EventLoop
participant Adapter
participant HomePort
entity dev
participant Application
activate EventLoop
group An instance of Problem A
EventLoop -> Adapter: callback()
activate Adapter #Gold
Adapter -> HomePort: add_device()
activate HomePort
create dev
HomePort -> dev: create()
Adapter <-- HomePort
deactivate HomePort
EventLoop <-- Adapter
deactivate Adapter
EventLoop -> Application: callback()
activate Application #DarkSalmon
Application -> HomePort: get_device()
activate HomePort
Application <-- HomePort: dev
note right: Application has pointer to dev
deactivate HomePort
Application -> HomePort: request()
activate HomePort
HomePort -> Adapter: request()
activate Adapter #Gold
Adapter -> HomePort: remove_device()
activate HomePort
HomePort -> dev: destroy()
destroy dev
Adapter <-- HomePort
deactivate HomePort
HomePort <-- Adapter
deactivate Adapter
Application <-- HomePort
note right: Pointer is no longer valid
deactivate HomePort
EventLoop <-- Application
deactivate Application
deactivate dev
end group
newpage
group A more complicated instance of Problem A
EventLoop -> Application: callback()
activate Application #DarkSalmon
Application -> HomePort: request()
activate HomePort
HomePort -> Adapter: request()
activate Adapter #DarkSalmon
Adapter -> HomePort: respond()
activate HomePort
HomePort -> Application: on_response()
activate Application #Gold
HomePort <-- Application
deactivate Application
Adapter <-- HomePort
deactivate HomePort
HomePort <-- Adapter
deactivate Adapter
Application <-- HomePort
deactivate HomePort
EventLoop <-- Application
deactivate Application
end
newpage
' create dev
' EventLoop -> dev
' activate dev
group A solution to problem A
EventLoop -> Application: callback()
activate Application #Gold
Application -> HomePort: get_device()
activate HomePort
Application <-- HomePort: dev
note right: Application has pointer to dev
deactivate HomePort
Application -> HomePort: request()
activate HomePort
HomePort -> EventLoop: Add a watcher
Application <-- HomePort
note right: Pointer is still valid
deactivate HomePort
EventLoop <-- Application
deactivate Application
EventLoop -> HomePort: Watcher triggers
activate HomePort
HomePort -> Adapter: request()
activate Adapter #Gold
Adapter -> HomePort: remove_device()
activate HomePort
HomePort -> dev: destroy()
destroy dev
Adapter <-- HomePort
deactivate HomePort
HomePort <-- Adapter
deactivate Adapter
EventLoop <-- HomePort
deactivate HomePort
end
newpage
group An instance of problem B
EventLoop -> Application: callback()
activate Application #Gold
Application -> HomePort: get_device()
activate HomePort
Application <-- HomePort: dev
note right: Application has pointer to dev
deactivate HomePort
Application -> HomePort: request()
activate HomePort
HomePort -> EventLoop: Add a watcher
Application <-- HomePort
note right: Pointer is still valid
deactivate HomePort
EventLoop <-- Application
deactivate Application
EventLoop -> Adapter: callback()
activate Adapter #Gold
Adapter -> HomePort: remove_device()
activate HomePort
HomePort -> dev
destroy dev
Adapter <-- HomePort
deactivate HomePort
EventLoop <-- Adapter
deactivate Adapter
EventLoop -> HomePort: Watcher triggers
activate HomePort
HomePort -> Adapter: request()
activate Adapter #Gold
HomePort <-- Adapter
deactivate Adapter
EventLoop <-- HomePort
deactivate HomePort
end
deactivate EventLoop
@enduml