Statistics
| Branch: | Revision:

urtware / doc / statediagrams / subscriber / receive.uml @ 6ebd2388

History | View | Annotate | Download (3.108 KB)

1
/'
2
µRtWare is a lightweight publish/subscribe middleware for real-time
3
applications. It was developed as part of the software habitat for the
4
Autonomous Mini Robot [1] (AMiRo) but can be used for other purposes as well.
5

    
6
Copyright (C) 2018..2018  Thomas Schöpping et al.
7

    
8
This program is free software: you can redistribute it and/or modify
9
it under the terms of the GNU General Public License as published by
10
the Free Software Foundation, either version 3 of the License, or
11
(at your option) any later version.
12

    
13
This program is distributed in the hope that it will be useful,
14
but WITHOUT ANY WARRANTY; without even the implied warranty of
15
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16
GNU General Public License for more details.
17

    
18
You should have received a copy of the GNU General Public License
19
along with this program.  If not, see <http://www.gnu.org/licenses/>.
20
'/
21

    
22
@startuml
23

    
24
title **µRtWare**\nurtSubscriberFetchMessage()\n
25

    
26

    
27

    
28
start
29
note
30
  event received
31
endnote
32
:lock topic;
33
note
34
  The message list is part of the topic and must be locked.
35
endnote
36
if (Is HRT subscriber?) then (yes)
37
  :lock next message;
38
  if (Fetch next or latest message?) then (next)
39
  else (latest)
40
    partition "iterate to latest" {
41
      :lock next message;
42
      note
43
        locked two messaged ahead
44
      endnote
45
      while (Timestamp of next message is younger than current?) is (yes)
46
        fork
47
          fork
48
            :decremenet HRT counter of current message;
49
          fork again
50
            :update QoS timer (delay);
51
            note
52
              no lock required since this timer is only accessed when the topic is locked
53
            endnote
54
          endfork
55
          :unlock current message;
56
        fork again
57
          :lock next message;
58
        endfork
59
      endwhile (no)
60
      :unlock next message;
61
      note
62
        one message ahead still locked
63
        but HRT counter not yet decremented
64
      endnote
65
    }
66
  endif
67
  fork
68
    :decrement HRT counter of current message;
69
  fork again
70
    :update QoS timer (delay);
71
    note
72
      no lock required since this timer is only accessed when the topic is locked
73
    endnote
74
  endfork
75
else (no)
76
  :lock last read message;
77
  if (Timestamp equals local copy?) then (yes)
78
  else (no)
79
    partition "find oldest valid message" {
80
      repeat
81
        fork
82
          :unlock current message;
83
        fork again
84
          :lock next message;
85
        forkend
86
      repeat while (while timestamp of next is younger than of current)
87
    }
88
  endif
89
  if (Fetch next or latest message?) then (next)
90
  else (latest)
91
    partition "iterate to latest" {
92
      :lock next message;
93
      note
94
        locked two messages ahead
95
      endnote
96
      while (Timestamp of next message is younger then current?) is (yes)
97
        fork
98
          :unlock current message;
99
        fork again
100
          :lock next message;
101
        endfork
102
        :unlock next message;
103
        note
104
          one message ahead still locked
105
        endnote
106
      endwhile (no)
107
    }
108
  endif
109
endif
110
fork
111
  :set pointer to last message read to locked message;
112
fork again
113
  :copy timestamp of message;
114
endfork
115
:unlock message;
116
:unlock topic;
117
stop
118

    
119
@enduml