From 9d31eb4296b21d64584c8ce3b9f68bfe3a1b07e8 Mon Sep 17 00:00:00 2001 From: Sai Kishor Kothakota Date: Fri, 17 May 2024 23:16:03 +0200 Subject: [PATCH] simplify the logic inside the thread Co-authored-by: atzaros <128592691+atzaros@users.noreply.github.com> --- .../controller_interface/async_function_handler.hpp | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/controller_interface/include/controller_interface/async_function_handler.hpp b/controller_interface/include/controller_interface/async_function_handler.hpp index b32fbdb1f1a..e8ec70c0f14 100644 --- a/controller_interface/include/controller_interface/async_function_handler.hpp +++ b/controller_interface/include/controller_interface/async_function_handler.hpp @@ -225,16 +225,13 @@ class AsyncFunctionHandler std::unique_lock lock(async_mtx_); async_update_condition_.wait( lock, [this] { return trigger_in_progress_ || async_update_stop_; }); - if (async_update_stop_) + if (!async_update_stop_) { - trigger_in_progress_ = false; - cycle_end_condition_.notify_one(); - break; + async_update_return_ = async_function_(current_update_time_, current_update_period_); } - async_update_return_ = async_function_(current_update_time_, current_update_period_); trigger_in_progress_ = false; } - cycle_end_condition_.notify_one(); + cycle_end_condition_.notify_all(); } }); }