Statistics
| Branch: | Revision:

urtware / doc / activitydiagrams / service / urtServiceDispatch.uml @ 17d978fe

History | View | Annotate | Download (2.796 KB)

1 7491c395 Thomas Schöpping
/'
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..2020  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
/'### INTRO ##################################################################'/
23
24
@startuml
25
26 2d315870 Thomas Schöpping
title **µRtWare**\nurtServiceDispatch()\n
27 7491c395 Thomas Schöpping
28 ee83a495 Thomas Schöpping
/'### PARAMETERS & RETURN ####################################################'/
29 7491c395 Thomas Schöpping
30
note
31 ee83a495 Thomas Schöpping
  -- **service** : urt_service_t* --
32 2d315870 Thomas Schöpping
  The service to dispatch a request for.
33 7491c395 Thomas Schöpping
  Must not be ""NULL"".
34 2d315870 Thomas Schöpping
  -- **payload** : void* --
35
  Pointer where to store the payload (if any).
36
  May be ""NULL"" if the service expects no payload.
37
  -- **bytes** : size_t --
38
  Size of the payload in bytes.
39
  Must be 0 if the service expects no payload.
40 ee83a495 Thomas Schöpping
  ====
41 2d315870 Thomas Schöpping
  -- **return** : urt_baserequest_t* --
42
  Pointer to the request to be processed next.
43
  May be ""NULL"" if there are no pending requests.
44 ee83a495 Thomas Schöpping
endnote
45 7491c395 Thomas Schöpping
46
/'### PROCEDURE ##############################################################'/
47
48 ee83a495 Thomas Schöpping
start
49 2d315870 Thomas Schöpping
:lock service;
50
if (Request list empty?) then (no)
51
  :access first request (""requestQueue_front"");
52
  note
53
    No need to lock the request because it is enqueued at this point.
54
    Enqueued requests must not be altered without the according service to be locked.
55
    Since the service has been locked, no enqueued requests will be modified externally.
56
  endnote
57
  :proceed ""requestQueue_front"" pointer;
58 dd31cb03 Thomas Schöpping
  fork
59 2d315870 Thomas Schöpping
    if (This was the last request (pointer became ""NULL"")?) then (yes)
60
      :set ""requestQueue_back"" to ""NULL"";
61 dd31cb03 Thomas Schöpping
    else (no)
62 2d315870 Thomas Schöpping
      :set request ""next"" pointer to ""NULL"";
63 dd31cb03 Thomas Schöpping
    endif
64
  fork again
65 2d315870 Thomas Schöpping
    if (This was the last HRT request?) then (yes)
66
      :set ""requestQueue_hrtBack"" to ""NULL"";
67
    elseif (This was the last FRT/SRT request?) then (yes)
68
      :set ""requestQueue_fsrtBack"" to ""NULL"";
69 dd31cb03 Thomas Schöpping
    else (no)
70
    endif
71 2d315870 Thomas Schöpping
  fork again
72
    :copy payload from request to argument;
73 dd31cb03 Thomas Schöpping
  endfork
74 2d315870 Thomas Schöpping
  :unlock service;
75
  stop
76
  note
77
    Returns pointer to the dispatched request.
78
  endnote
79
else (yes)
80
endif
81
:unlock service;
82 7491c395 Thomas Schöpping
stop
83
note
84 2d315870 Thomas Schöpping
  Returns ""NULL"".
85 ee83a495 Thomas Schöpping
endnote
86 7491c395 Thomas Schöpping
87
/'### OUTRO ##################################################################'/
88
89
@enduml