Skip to content

Commit

Permalink
fix events executor notify waitable to correctly set guard condition …
Browse files Browse the repository at this point in the history
…listeners

Signed-off-by: Alberto Soragna <alberto.soragna@gmail.com>
  • Loading branch information
alsora authored and timonegk committed May 13, 2022
1 parent 0c0ce61 commit 74c99e0
Showing 1 changed file with 12 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ class EventsExecutorNotifyWaitable final : public EventWaitable

RCLCPP_PUBLIC
void
add_guard_condition(const rclcpp::GuardCondition * guard_condition)
add_guard_condition(rclcpp::GuardCondition * guard_condition)
{
notify_guard_conditions_.push_back(guard_condition);
}
Expand All @@ -62,10 +62,16 @@ class EventsExecutorNotifyWaitable final : public EventWaitable
void
set_on_ready_callback(std::function<void(size_t, int)> callback) override
{
(void)callback;
// for (auto gc : notify_guard_conditions_) {
// gc->set_listener_callback();
// }
// The second argument of the callback should identify which guard condition
// triggered the event. However it's not relevant here as we only
// care about waking up the executor, so we pass a 0.
auto gc_callback = [callback](size_t count){
callback(count, 0);
};

for (auto gc : notify_guard_conditions_) {
gc->set_on_trigger_callback(gc_callback);
}
}

RCLCPP_PUBLIC
Expand All @@ -85,7 +91,7 @@ class EventsExecutorNotifyWaitable final : public EventWaitable
};

private:
std::list<const rclcpp::GuardCondition *> notify_guard_conditions_;
std::list<rclcpp::GuardCondition *> notify_guard_conditions_;
};

} // namespace executors
Expand Down

0 comments on commit 74c99e0

Please sign in to comment.