Skip to content

Commit e4e56ef

Browse files
author
Mauro Passerino
committed
Use QoS depth to limit callbacks count
Signed-off-by: Mauro Passerino <[email protected]>
1 parent b0ff053 commit e4e56ef

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

rclcpp/include/rclcpp/experimental/subscription_intra_process_base.hpp

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -142,8 +142,12 @@ class SubscriptionIntraProcessBase : public rclcpp::Waitable
142142
on_new_message_callback_ = new_callback;
143143

144144
if (unread_count_ > 0) {
145-
// Use qos profile depth as upper bound for unread_count_
146-
on_new_message_callback_(std::min(unread_count_, qos_profile_.depth));
145+
if (qos_profile_.history == RMW_QOS_POLICY_HISTORY_KEEP_ALL || qos_profile_.depth == 0) {
146+
on_new_message_callback_(unread_count_);
147+
} else {
148+
// Use qos profile depth as upper bound for unread_count_
149+
on_new_message_callback_(std::min(unread_count_, qos_profile_.depth));
150+
}
147151
unread_count_ = 0;
148152
}
149153
}

0 commit comments

Comments
 (0)