From 1f35b10df6ef1c22021faab519663394b7eb7e5e Mon Sep 17 00:00:00 2001 From: Artem Shumov Date: Tue, 25 Jan 2022 22:20:43 +0300 Subject: [PATCH] Add the debugging exception --- rmw_fastrtps_shared_cpp/src/types/guard_condition.hpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/rmw_fastrtps_shared_cpp/src/types/guard_condition.hpp b/rmw_fastrtps_shared_cpp/src/types/guard_condition.hpp index ab5076522..974571d25 100644 --- a/rmw_fastrtps_shared_cpp/src/types/guard_condition.hpp +++ b/rmw_fastrtps_shared_cpp/src/types/guard_condition.hpp @@ -53,6 +53,9 @@ class GuardCondition attachCondition(std::mutex * conditionMutex, std::condition_variable * conditionVariable) { std::lock_guard lock(internalMutex_); + if (conditionMutex_ != nullptr) { + throw std::runtime_error("The guard condition had already been attached"); + } conditionMutex_ = conditionMutex; conditionVariable_ = conditionVariable; }