Skip to content

Commit

Permalink
have the executor notify waitable fiddle with guard condition callbac…
Browse files Browse the repository at this point in the history
…ks only if necessary

Signed-off-by: Alberto Soragna <[email protected]>
  • Loading branch information
alsora committed Apr 14, 2023
1 parent 2f74b41 commit 0816eaf
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions rclcpp/src/rclcpp/executors/executor_notify_waitable.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,9 @@ ExecutorNotifyWaitable::add_guard_condition(rclcpp::GuardCondition::WeakPtr weak
auto guard_condition = weak_guard_condition.lock();
if (guard_condition && notify_guard_conditions_.count(weak_guard_condition) == 0) {
notify_guard_conditions_.insert(weak_guard_condition);
guard_condition->set_on_trigger_callback(on_ready_callback_);
if (on_ready_callback_) {
guard_condition->set_on_trigger_callback(on_ready_callback_);
}
}
}

Expand All @@ -163,7 +165,8 @@ ExecutorNotifyWaitable::remove_guard_condition(rclcpp::GuardCondition::WeakPtr w
if (notify_guard_conditions_.count(weak_guard_condition) != 0) {
notify_guard_conditions_.erase(weak_guard_condition);
auto guard_condition = weak_guard_condition.lock();
if (guard_condition) {
// If this notify waitable doesn't have an on_ready_callback, then there's nothing to unset
if (guard_condition && on_ready_callback_) {
guard_condition->set_on_trigger_callback(nullptr);
}
}
Expand Down

0 comments on commit 0816eaf

Please sign in to comment.