Skip to content

Commit

Permalink
Always use the guard condition to notify
Browse files Browse the repository at this point in the history
Signed-off-by: Miguel Company <MiguelCompany@eprosima.com>
  • Loading branch information
MiguelCompany authored Apr 6, 2023
1 parent 60a3017 commit e9004b5
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 10 deletions.
4 changes: 1 addition & 3 deletions rmw_fastrtps_shared_cpp/src/custom_publisher_info.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -368,9 +368,7 @@ void RMWPublisherEvent::update_matched(
matched_status_.current_count_change += current_count_change;
matched_changes_ = true;

if (on_new_event_cb_[RMW_EVENT_PUBLICATION_MATCHED]) {
trigger_event(RMW_EVENT_PUBLICATION_MATCHED);
}
trigger_event(RMW_EVENT_PUBLICATION_MATCHED);
}

void RMWPublisherEvent::trigger_event(rmw_event_type_t event_type)
Expand Down
4 changes: 1 addition & 3 deletions rmw_fastrtps_shared_cpp/src/custom_subscriber_info.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -494,9 +494,7 @@ void RMWSubscriptionEvent::update_matched(
matched_status_.current_count_change += current_count_change;
matched_changes_ = true;

if (on_new_event_cb_[RMW_EVENT_SUBSCRIPTION_MATCHED]) {
trigger_event(RMW_EVENT_SUBSCRIPTION_MATCHED);
}
trigger_event(RMW_EVENT_SUBSCRIPTION_MATCHED);
}

void RMWSubscriptionEvent::trigger_event(rmw_event_type_t event_type)
Expand Down
16 changes: 12 additions & 4 deletions rmw_fastrtps_shared_cpp/src/rmw_event.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -142,10 +142,18 @@ __rmw_init_event(
rmw_event->data = data;
rmw_event->event_type = event_type;
CustomEventInfo * event = static_cast<CustomEventInfo *>(rmw_event->data);
eprosima::fastdds::dds::StatusMask status_mask =
event->get_listener()->get_statuscondition().get_enabled_statuses();
status_mask |= rmw_fastrtps_shared_cpp::internal::rmw_event_to_dds_statusmask(event_type);
event->get_listener()->get_statuscondition().set_enabled_statuses(status_mask);

// For matched events, we always notify the waitset with the guard condition,
// so we will not enable them on the status condition.
bool is_matched_event =
(RMW_EVENT_PUBLICATION_MATCHED == event_type) ||
(RMW_EVENT_SUBSCRIPTION_MATCHED == event_type);
if (!is_matched_event) {
eprosima::fastdds::dds::StatusMask status_mask =
event->get_listener()->get_statuscondition().get_enabled_statuses();
status_mask |= rmw_fastrtps_shared_cpp::internal::rmw_event_to_dds_statusmask(event_type);
event->get_listener()->get_statuscondition().set_enabled_statuses(status_mask);
}

return RMW_RET_OK;
}
Expand Down

0 comments on commit e9004b5

Please sign in to comment.