Skip to content

Commit

Permalink
Only keep subscription count on custom_publisher_info.
Browse files Browse the repository at this point in the history
Signed-off-by: Miguel Company <[email protected]>
  • Loading branch information
MiguelCompany committed Mar 1, 2022
1 parent 6c4584b commit eaa72a3
Showing 1 changed file with 3 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -76,11 +76,7 @@ class PubListener : public EventListenerInterface, public eprosima::fastdds::dds
const eprosima::fastdds::dds::PublicationMatchedStatus & info) final
{
std::lock_guard<std::mutex> lock(internalMutex_);
if (info.current_count_change == 1) {
subscriptions_.insert(eprosima::fastrtps::rtps::iHandle2GUID(info.last_subscription_handle));
} else if (info.current_count_change == -1) {
subscriptions_.erase(eprosima::fastrtps::rtps::iHandle2GUID(info.last_subscription_handle));
}
subscription_count_ = info.current_count;
}

RMW_FASTRTPS_SHARED_CPP_PUBLIC
Expand Down Expand Up @@ -119,7 +115,7 @@ class PubListener : public EventListenerInterface, public eprosima::fastdds::dds
size_t subscriptionCount()
{
std::lock_guard<std::mutex> lock(internalMutex_);
return subscriptions_.size();
return subscription_count_;
}

void
Expand All @@ -141,7 +137,7 @@ class PubListener : public EventListenerInterface, public eprosima::fastdds::dds
private:
mutable std::mutex internalMutex_;

std::set<eprosima::fastrtps::rtps::GUID_t> subscriptions_
std::size_t subscription_count_ = 0
RCPPUTILS_TSA_GUARDED_BY(internalMutex_);

std::atomic_bool deadline_changes_;
Expand Down

0 comments on commit eaa72a3

Please sign in to comment.