Skip to content

Commit ba01023

Browse files
committed
[#24061] Removed lock in DdsPipe + separated 'update_filters()'
Signed-off-by: danipiza <dpizarrogallego@gmail.com>
1 parent b8e75ad commit ba01023

10 files changed

Lines changed: 79 additions & 70 deletions

File tree

ddspipe_core/include/ddspipe_core/interface/IParticipant.hpp

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -148,17 +148,22 @@ class IParticipant
148148
virtual void clear_topic_partitions() = 0;
149149

150150
/**
151-
* Update the filters data structures of the participant
151+
* Update the partition filter data structure of the participant
152152
*
153-
* @param [in] flag : Flag to update the partitions or topic filter.
154153
* @param [in] partitions : Set of partitions for the new filter of partitions.
154+
*/
155+
DDSPIPE_CORE_DllAPI
156+
virtual void update_partitions(
157+
std::set<std::string> partitions) = 0;
158+
159+
/**
160+
* Update the content_topicfilter data structure of the participant
161+
*
155162
* @param [in] topic_name : Name of the topic.
156163
* @param [in] expression : Expression for the Content Filtered Topic
157164
*/
158165
DDSPIPE_CORE_DllAPI
159-
virtual void update_filters(
160-
const int flag,
161-
std::set<std::string> partitions,
166+
virtual void update_content_topicfilter(
162167
const std::string& topic_name,
163168
const std::string& expression) = 0;
164169

ddspipe_core/src/cpp/core/DdsPipe.cpp

Lines changed: 9 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -301,24 +301,19 @@ void DdsPipe::discovered_endpoint_nts_(
301301
{
302302
// there is a filter.
303303
// update the track of the topic to
304-
// add the partition in the reader if it is in the filter
304+
// add the partition in the reader if it is in the filter
305305

306-
// update partitions under bridges_mutex_
306+
const auto bridge_it = bridges_.find(utils::Heritable<DdsTopic>::make_heritable(endpoint.topic));
307+
// add the specific partition of the endpoint in the bridges topic.
308+
if (bridge_it != bridges_.end())
307309
{
308-
std::lock_guard<std::mutex> lock(bridges_mutex_);
310+
std::ostringstream guid_ss;
311+
guid_ss << endpoint.guid;
309312

310-
const auto bridge_it = bridges_.find(utils::Heritable<DdsTopic>::make_heritable(endpoint.topic));
311-
// add the specific partition of the endpoint in the bridges topic.
312-
if (bridge_it != bridges_.end())
313+
const auto part_it = endpoint.specific_partitions.find(guid_ss.str());
314+
if (part_it != endpoint.specific_partitions.end())
313315
{
314-
std::ostringstream guid_ss;
315-
guid_ss << endpoint.guid;
316-
317-
const auto part_it = endpoint.specific_partitions.find(guid_ss.str());
318-
if (part_it != endpoint.specific_partitions.end())
319-
{
320-
bridge_it->second->add_partition_to_topic(guid_ss.str(), part_it->second);
321-
}
316+
bridge_it->second->add_partition_to_topic(guid_ss.str(), part_it->second);
322317
}
323318
}
324319

@@ -653,9 +648,6 @@ void DdsPipe::update_content_filter(
653648
void DdsPipe::update_filter(
654649
const std::set<std::string> filter_partition_set)
655650
{
656-
// Avoid possible datarace with partitions filter
657-
std::lock_guard<std::mutex> lock(bridges_mutex_);
658-
659651
filter_partition_ = std::move(filter_partition_set);
660652
}
661653

ddspipe_participants/include/ddspipe_participants/participant/auxiliar/BlankParticipant.hpp

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -94,11 +94,14 @@ class BlankParticipant : public core::IParticipant
9494
DDSPIPE_PARTICIPANTS_DllAPI
9595
void clear_topic_partitions() override;
9696

97-
//! Override update_filters() IParticipant method
97+
//! Override update_partitions() IParticipant method
9898
DDSPIPE_PARTICIPANTS_DllAPI
99-
virtual void update_filters(
100-
const int flag,
101-
std::set<std::string> partitions,
99+
virtual void update_partitions(
100+
std::set<std::string> partitions) override;
101+
102+
//! Override update_content_topicfilter() IParticipant method
103+
DDSPIPE_PARTICIPANTS_DllAPI
104+
virtual void update_content_topicfilter(
102105
const std::string& topic_name,
103106
const std::string& expression) override;
104107

ddspipe_participants/include/ddspipe_participants/participant/dds/CommonParticipant.hpp

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -137,14 +137,19 @@ class CommonParticipant : public core::IParticipant
137137
DDSPIPE_PARTICIPANTS_DllAPI
138138
void clear_topic_partitions() override;
139139

140-
//! Override update_filters() IParticipant method
140+
//! Override update_partitions() IParticipant method
141141
DDSPIPE_PARTICIPANTS_DllAPI
142-
virtual void update_filters(
143-
const int flag,
144-
std::set<std::string> partitions,
142+
virtual void update_partitions(
143+
std::set<std::string> partitions) override;
144+
145+
//! Override update_content_topicfilter() IParticipant method
146+
DDSPIPE_PARTICIPANTS_DllAPI
147+
virtual void update_content_topicfilter(
145148
const std::string& topic_name,
146149
const std::string& expression) override;
147150

151+
// TODO. danip separate
152+
148153
/////////////////////////
149154
// LISTENER METHODS
150155
/////////////////////////

ddspipe_participants/include/ddspipe_participants/participant/dynamic_types/SchemaParticipant.hpp

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -95,11 +95,14 @@ class SchemaParticipant : public core::IParticipant
9595
DDSPIPE_PARTICIPANTS_DllAPI
9696
void clear_topic_partitions() override;
9797

98-
//! Override update_filters() IParticipant method
98+
//! Override update_partitions() IParticipant method
9999
DDSPIPE_PARTICIPANTS_DllAPI
100-
virtual void update_filters(
101-
const int flag,
102-
std::set<std::string> partitions,
100+
virtual void update_partitions(
101+
std::set<std::string> partitions) override;
102+
103+
//! Override update_content_topicfilter() IParticipant method
104+
DDSPIPE_PARTICIPANTS_DllAPI
105+
virtual void update_content_topicfilter(
103106
const std::string& topic_name,
104107
const std::string& expression) override;
105108

ddspipe_participants/include/ddspipe_participants/participant/rtps/CommonParticipant.hpp

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -147,11 +147,14 @@ class CommonParticipant
147147
DDSPIPE_PARTICIPANTS_DllAPI
148148
void clear_topic_partitions() override;
149149

150-
//! Override update_filters() IParticipant method
150+
//! Override update_partitions() IParticipant method
151151
DDSPIPE_PARTICIPANTS_DllAPI
152-
virtual void update_filters(
153-
const int flag,
154-
std::set<std::string> partitions,
152+
virtual void update_partitions(
153+
std::set<std::string> partitions) override;
154+
155+
//! Override update_content_topicfilter() IParticipant method
156+
DDSPIPE_PARTICIPANTS_DllAPI
157+
virtual void update_content_topicfilter(
155158
const std::string& topic_name,
156159
const std::string& expression) override;
157160

ddspipe_participants/src/cpp/participant/auxiliar/BlankParticipant.cpp

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -141,9 +141,13 @@ void BlankParticipant::clear_topic_partitions()
141141
partition_names.clear();
142142
}
143143

144-
void BlankParticipant::update_filters(
145-
const int flag,
146-
std::set<std::string> partitions,
144+
void BlankParticipant::update_partitions(
145+
std::set<std::string> partitions)
146+
{
147+
// Nothing
148+
}
149+
150+
void BlankParticipant::update_content_topicfilter(
147151
const std::string& topic_name,
148152
const std::string& expression)
149153
{

ddspipe_participants/src/cpp/participant/dds/CommonParticipant.cpp

Lines changed: 8 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -547,22 +547,17 @@ fastdds::dds::Topic* CommonParticipant::topic_related_(
547547
return dds_topic;
548548
}
549549

550-
void CommonParticipant::update_filters(
551-
const int flag,
552-
std::set<std::string> partitions,
550+
void CommonParticipant::update_partitions(
551+
std::set<std::string> partitions)
552+
{
553+
partition_filter_set_ = std::move(partitions);
554+
}
555+
556+
void CommonParticipant::update_content_topicfilter(
553557
const std::string& topic_name,
554558
const std::string& expression)
555559
{
556-
if (flag == 0)
557-
{
558-
// partitions
559-
partition_filter_set_ = std::move(partitions);
560-
}
561-
else
562-
{
563-
// content_topicfilter
564-
topic_filter_dict_[topic_name] = expression;
565-
}
560+
topic_filter_dict_[topic_name] = expression;
566561
}
567562

568563
bool CommonParticipant::add_topic_partition(

ddspipe_participants/src/cpp/participant/dynamic_types/SchemaParticipant.cpp

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -175,9 +175,13 @@ void SchemaParticipant::clear_topic_partitions()
175175
partition_names.clear();
176176
}
177177

178-
void SchemaParticipant::update_filters(
179-
const int flag,
180-
std::set<std::string> partitions,
178+
void SchemaParticipant::update_partitions(
179+
std::set<std::string> partitions)
180+
{
181+
// Nothing
182+
}
183+
184+
void SchemaParticipant::update_content_topicfilter(
181185
const std::string& topic_name,
182186
const std::string& expression)
183187
{

ddspipe_participants/src/cpp/participant/rtps/CommonParticipant.cpp

Lines changed: 8 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -645,22 +645,17 @@ void CommonParticipant::clear_topic_partitions()
645645
partition_names.clear();
646646
}
647647

648-
void CommonParticipant::update_filters(
649-
const int flag,
650-
std::set<std::string> partitions,
648+
void CommonParticipant::update_partitions(
649+
std::set<std::string> partitions)
650+
{
651+
partition_filter_set_ = std::move(partitions);
652+
}
653+
654+
void CommonParticipant::update_content_topicfilter(
651655
const std::string& topic_name,
652656
const std::string& expression)
653657
{
654-
if (flag == 0)
655-
{
656-
// partitions
657-
partition_filter_set_ = std::move(partitions);
658-
}
659-
else
660-
{
661-
// content_topicfilter
662-
// nothing
663-
}
658+
// Nothing
664659
}
665660

666661
} /* namespace rtps */

0 commit comments

Comments
 (0)