From 1d7042fb3d1c7b9b2a990722b937acc496d5dfd2 Mon Sep 17 00:00:00 2001 From: Emerson Knapp Date: Tue, 20 Jun 2023 13:46:34 -0700 Subject: [PATCH] Use recursive_mutex to allow callbacks to reenter Signed-off-by: Emerson Knapp --- .../include/rmw_connextdds/rmw_waitset_std.hpp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/rmw_connextdds_common/include/rmw_connextdds/rmw_waitset_std.hpp b/rmw_connextdds_common/include/rmw_connextdds/rmw_waitset_std.hpp index 45bcedf6..6c6412fb 100644 --- a/rmw_connextdds_common/include/rmw_connextdds/rmw_waitset_std.hpp +++ b/rmw_connextdds_common/include/rmw_connextdds/rmw_waitset_std.hpp @@ -83,7 +83,7 @@ class RMW_Connext_Condition bool & already_active, FunctorT && check_trigger) { - std::lock_guard lock(this->mutex_internal); + std::lock_guard lock(this->mutex_internal); already_active = check_trigger(); if (!already_active) { this->waitset_mutex = waitset_mutex; @@ -95,7 +95,7 @@ class RMW_Connext_Condition void detach(FunctorT && on_detached) { - std::lock_guard lock(this->mutex_internal); + std::lock_guard lock(this->mutex_internal); this->waitset_mutex = nullptr; this->waitset_condition = nullptr; on_detached(); @@ -107,7 +107,7 @@ class RMW_Connext_Condition void update_state(FunctorT && update_condition, const bool notify) { - std::lock_guard internal_lock(this->mutex_internal); + std::lock_guard internal_lock(this->mutex_internal); if (nullptr != this->waitset_mutex) { std::lock_guard lock(*this->waitset_mutex); @@ -125,7 +125,7 @@ class RMW_Connext_Condition void perform_action_and_update_state(FunctorA && action, FunctorT && update_condition) { - std::lock_guard internal_lock(this->mutex_internal); + std::lock_guard internal_lock(this->mutex_internal); action(); @@ -138,7 +138,7 @@ class RMW_Connext_Condition } protected: - std::mutex mutex_internal; + std::recursive_mutex mutex_internal; std::mutex * waitset_mutex; std::condition_variable * waitset_condition;