Skip to content

Commit

Permalink
Use get_subscription_matched_status on rmw_subscription.
Browse files Browse the repository at this point in the history
Signed-off-by: Miguel Company <[email protected]>
  • Loading branch information
MiguelCompany committed Mar 7, 2022
1 parent c8eb812 commit 9d55fd7
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 19 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@

#include "fastdds/dds/core/status/DeadlineMissedStatus.hpp"
#include "fastdds/dds/core/status/LivelinessChangedStatus.hpp"
#include "fastdds/dds/core/status/SubscriptionMatchedStatus.hpp"
#include "fastdds/dds/subscriber/DataReader.hpp"
#include "fastdds/dds/subscriber/DataReaderListener.hpp"
#include "fastdds/dds/topic/TypeSupport.hpp"
Expand Down Expand Up @@ -89,14 +88,6 @@ class SubListener : public EventListenerInterface, public eprosima::fastdds::dds
eprosima::fastdds::dds::DataReader * reader,
const eprosima::fastdds::dds::SubscriptionMatchedStatus & info) final
{
{
std::lock_guard<std::mutex> lock(internalMutex_);
if (info.current_count_change == 1) {
publishers_.insert(eprosima::fastrtps::rtps::iHandle2GUID(info.last_publication_handle));
} else if (info.current_count_change == -1) {
publishers_.erase(eprosima::fastrtps::rtps::iHandle2GUID(info.last_publication_handle));
}
}
update_has_data(reader);
}

Expand Down Expand Up @@ -188,12 +179,6 @@ class SubListener : public EventListenerInterface, public eprosima::fastdds::dds
data_.store(has_data, std::memory_order_relaxed);
}

size_t publisherCount()
{
std::lock_guard<std::mutex> lock(internalMutex_);
return publishers_.size();
}

// Provide handlers to perform an action when a
// new event from this listener has ocurred
void
Expand Down Expand Up @@ -242,8 +227,6 @@ class SubListener : public EventListenerInterface, public eprosima::fastdds::dds
std::mutex * conditionMutex_ RCPPUTILS_TSA_GUARDED_BY(internalMutex_);
std::condition_variable * conditionVariable_ RCPPUTILS_TSA_GUARDED_BY(internalMutex_);

std::set<eprosima::fastrtps::rtps::GUID_t> publishers_ RCPPUTILS_TSA_GUARDED_BY(internalMutex_);

rmw_event_callback_t on_new_message_cb_{nullptr};
std::mutex on_new_message_m_;
size_t qos_depth_;
Expand Down
6 changes: 4 additions & 2 deletions rmw_fastrtps_shared_cpp/src/rmw_subscription.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
#include "rmw/error_handling.h"
#include "rmw/rmw.h"

#include "fastdds/dds/core/status/SubscriptionMatchedStatus.hpp"
#include "fastdds/dds/subscriber/DataReader.hpp"
#include "fastdds/dds/subscriber/qos/DataReaderQos.hpp"

Expand Down Expand Up @@ -87,8 +88,9 @@ __rmw_subscription_count_matched_publishers(
size_t * publisher_count)
{
auto info = static_cast<CustomSubscriberInfo *>(subscription->data);

*publisher_count = info->listener_->publisherCount();
eprosima::fastdds::dds::SubscriptionMatchedStatus status{};
info->data_reader_->get_subscription_matched_status(status);
*publisher_count = status.current_count;

return RMW_RET_OK;
}
Expand Down

0 comments on commit 9d55fd7

Please sign in to comment.