Skip to content

Commit

Permalink
check gc
Browse files Browse the repository at this point in the history
Signed-off-by: Karsten Knese <Karsten1987@users.noreply.github.com>
  • Loading branch information
Karsten1987 committed Jul 27, 2021
1 parent 4db62da commit df823ea
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions rclcpp/include/rclcpp/wait_for_message.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -43,13 +43,11 @@ bool wait_for_message(
std::shared_ptr<rclcpp::Context> context,
std::chrono::duration<Rep, Period> time_to_wait = std::chrono::duration<Rep, Period>(-1))
{
auto shutdown_requested = false;
auto gc = std::make_shared<rclcpp::GuardCondition>(context);
auto shutdown_callback_handle = context->add_on_shutdown_callback(
[weak_gc = std::weak_ptr<rclcpp::GuardCondition>{gc}, &shutdown_requested]() {
[weak_gc = std::weak_ptr<rclcpp::GuardCondition>{gc}]() {
auto strong_gc = weak_gc.lock();
if (strong_gc) {
shutdown_requested = true;
strong_gc->trigger();
}
});
Expand All @@ -61,7 +59,8 @@ bool wait_for_message(
if (ret.kind() != rclcpp::WaitResultKind::Ready) {
return false;
}
if (shutdown_requested) {

if (wait_set.get_rcl_wait_set().guard_conditions[0]) {
return false;
}

Expand Down

0 comments on commit df823ea

Please sign in to comment.