/src/Fast-DDS/include/fastdds/rtps/attributes/RTPSParticipantAllocationAttributes.hpp
Line | Count | Source (jump to first uncovered line) |
1 | | // Copyright 2019 Proyectos y Sistemas de Mantenimiento SL (eProsima). |
2 | | // |
3 | | // Licensed under the Apache License, Version 2.0 (the "License"); |
4 | | // you may not use this file except in compliance with the License. |
5 | | // You may obtain a copy of the License at |
6 | | // |
7 | | // http://www.apache.org/licenses/LICENSE-2.0 |
8 | | // |
9 | | // Unless required by applicable law or agreed to in writing, software |
10 | | // distributed under the License is distributed on an "AS IS" BASIS, |
11 | | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
12 | | // See the License for the specific language governing permissions and |
13 | | // limitations under the License. |
14 | | |
15 | | /** |
16 | | * @file RTPSParticipantAllocationAttributes.hpp |
17 | | */ |
18 | | |
19 | | #ifndef _FASTDDS_RTPS_RTPSPARTICIPANTALLOCATIONATTRIBUTES_HPP_ |
20 | | #define _FASTDDS_RTPS_RTPSPARTICIPANTALLOCATIONATTRIBUTES_HPP_ |
21 | | |
22 | | #include <fastdds/rtps/builtin/data/ContentFilterProperty.hpp> |
23 | | |
24 | | #include <fastrtps/utils/collections/ResourceLimitedContainerConfig.hpp> |
25 | | |
26 | | namespace eprosima { |
27 | | namespace fastrtps { |
28 | | namespace rtps { |
29 | | |
30 | | /** |
31 | | * @brief Holds limits for collections of remote locators. |
32 | | */ |
33 | | struct RemoteLocatorsAllocationAttributes |
34 | | { |
35 | | bool operator ==( |
36 | | const RemoteLocatorsAllocationAttributes& b) const |
37 | 0 | { |
38 | 0 | return (this->max_unicast_locators == b.max_unicast_locators) && |
39 | 0 | (this->max_multicast_locators == b.max_multicast_locators); |
40 | 0 | } |
41 | | |
42 | | /** Maximum number of unicast locators per remote entity. |
43 | | * |
44 | | * This attribute controls the maximum number of unicast locators to keep for |
45 | | * each discovered remote entity (be it a participant, reader of writer). It is |
46 | | * recommended to use the highest number of local addresses found on all the systems |
47 | | * belonging to the same domain as this participant. |
48 | | */ |
49 | | size_t max_unicast_locators = 4u; |
50 | | |
51 | | /** Maximum number of multicast locators per remote entity. |
52 | | * |
53 | | * This attribute controls the maximum number of multicast locators to keep for |
54 | | * each discovered remote entity (be it a participant, reader of writer). The |
55 | | * default value of 1 is usually enough, as it doesn't make sense to add more |
56 | | * than one multicast locator per entity. |
57 | | */ |
58 | | size_t max_multicast_locators = 1u; |
59 | | }; |
60 | | |
61 | | /** |
62 | | * @brief Holds limits for send buffers allocations. |
63 | | */ |
64 | | struct SendBuffersAllocationAttributes |
65 | | { |
66 | | bool operator ==( |
67 | | const SendBuffersAllocationAttributes& b) const |
68 | 0 | { |
69 | 0 | return (this->preallocated_number == b.preallocated_number) && |
70 | 0 | (this->dynamic == b.dynamic); |
71 | 0 | } |
72 | | |
73 | | /** Initial number of send buffers to allocate. |
74 | | * |
75 | | * This attribute controls the initial number of send buffers to be allocated. |
76 | | * The default value of 0 will perform an initial guess of the number of buffers |
77 | | * required, based on the number of threads from which a send operation could be |
78 | | * started. |
79 | | */ |
80 | | size_t preallocated_number = 0u; |
81 | | |
82 | | /** Whether the number of send buffers is allowed to grow. |
83 | | * |
84 | | * This attribute controls how the buffer manager behaves when a send buffer is not |
85 | | * available. When true, a new buffer will be created. When false, it will wait for a |
86 | | * buffer to be returned. This is a trade-off between latency and dynamic allocations. |
87 | | */ |
88 | | bool dynamic = false; |
89 | | }; |
90 | | |
91 | | /** |
92 | | * @brief Holds limits for variable-length data. |
93 | | */ |
94 | | struct VariableLengthDataLimits |
95 | | { |
96 | | bool operator ==( |
97 | | const VariableLengthDataLimits& b) const |
98 | 0 | { |
99 | 0 | return (this->max_properties == b.max_properties) && |
100 | 0 | (this->max_user_data == b.max_user_data) && |
101 | 0 | (this->max_partitions == b.max_partitions) && |
102 | 0 | (this->max_datasharing_domains == b.max_datasharing_domains); |
103 | 0 | } |
104 | | |
105 | | //! Defines the maximum size (in octets) of properties data in the local or remote participant |
106 | | size_t max_properties = 0; |
107 | | //! Defines the maximum size (in octets) of user data in the local or remote participant |
108 | | size_t max_user_data = 0; |
109 | | //! Defines the maximum size (in octets) of partitions data |
110 | | size_t max_partitions = 0; |
111 | | //! Defines the maximum size (in elements) of the list of data sharing domain IDs |
112 | | size_t max_datasharing_domains = 0; |
113 | | }; |
114 | | |
115 | | /** |
116 | | * @brief Holds allocation limits affecting collections managed by a participant. |
117 | | */ |
118 | | struct RTPSParticipantAllocationAttributes |
119 | | { |
120 | | //! Holds limits for collections of remote locators. |
121 | | RemoteLocatorsAllocationAttributes locators; |
122 | | //! Defines the allocation behaviour for collections dependent on the total number of participants. |
123 | | ResourceLimitedContainerConfig participants; |
124 | | //! Defines the allocation behaviour for collections dependent on the total number of readers per participant. |
125 | | ResourceLimitedContainerConfig readers; |
126 | | //! Defines the allocation behaviour for collections dependent on the total number of writers per participant. |
127 | | ResourceLimitedContainerConfig writers; |
128 | | //! Defines the allocation behaviour for the send buffer manager. |
129 | | SendBuffersAllocationAttributes send_buffers; |
130 | | //! Holds limits for variable-length data |
131 | | VariableLengthDataLimits data_limits; |
132 | | //! Defines the allocation behavior of content filter discovery information |
133 | | fastdds::rtps::ContentFilterProperty::AllocationConfiguration content_filter; |
134 | | |
135 | | //! @return the allocation config for the total of readers in the system (participants * readers) |
136 | | ResourceLimitedContainerConfig total_readers() const |
137 | 0 | { |
138 | 0 | return total_endpoints(readers); |
139 | 0 | } |
140 | | |
141 | | //! @return the allocation config for the total of writers in the system (participants * writers) |
142 | | ResourceLimitedContainerConfig total_writers() const |
143 | 0 | { |
144 | 0 | return total_endpoints(writers); |
145 | 0 | } |
146 | | |
147 | | bool operator ==( |
148 | | const RTPSParticipantAllocationAttributes& b) const |
149 | 0 | { |
150 | 0 | return (this->locators == b.locators) && |
151 | 0 | (this->participants == b.participants) && |
152 | 0 | (this->readers == b.readers) && |
153 | 0 | (this->writers == b.writers) && |
154 | 0 | (this->send_buffers == b.send_buffers) && |
155 | 0 | (this->data_limits == b.data_limits); |
156 | 0 | } |
157 | | |
158 | | private: |
159 | | |
160 | | ResourceLimitedContainerConfig total_endpoints( |
161 | | const ResourceLimitedContainerConfig& endpoints) const |
162 | 0 | { |
163 | 0 | constexpr size_t max = (std::numeric_limits<size_t>::max)(); |
164 | 0 | size_t initial; |
165 | 0 | size_t maximum; |
166 | 0 | size_t increment; |
167 | 0 |
|
168 | 0 | initial = participants.initial * endpoints.initial; |
169 | 0 | maximum = (participants.maximum == max || endpoints.maximum == max) |
170 | 0 | ? max : participants.maximum * endpoints.maximum; |
171 | 0 | increment = (std::max)(participants.increment, endpoints.increment); |
172 | 0 |
|
173 | 0 | return { initial, maximum, increment }; |
174 | 0 | } |
175 | | |
176 | | }; |
177 | | |
178 | | const RTPSParticipantAllocationAttributes c_default_RTPSParticipantAllocationAttributes |
179 | | = RTPSParticipantAllocationAttributes(); |
180 | | |
181 | | } /* namespace rtps */ |
182 | | } /* namespace fastrtps */ |
183 | | } /* namespace eprosima */ |
184 | | |
185 | | #endif /* _FASTDDS_RTPS_RTPSPARTICIPANTALLOCATIONATTRIBUTES_HPP_ */ |