diff --git a/src/cpp/rtps/DataSharing/DataSharingListener.cpp b/src/cpp/rtps/DataSharing/DataSharingListener.cpp index ce1693f50eb..294e78bbc91 100644 --- a/src/cpp/rtps/DataSharing/DataSharingListener.cpp +++ b/src/cpp/rtps/DataSharing/DataSharingListener.cpp @@ -56,18 +56,15 @@ DataSharingListener::~DataSharingListener() void DataSharingListener::run() { - std::unique_lock lock(notification_->notification_->notification_mutex, std::defer_lock); while (is_running_.load()) { try { - lock.lock(); + std::unique_lock lock(notification_->notification_->notification_mutex); notification_->notification_->notification_cv.wait(lock, [&] { return !is_running_.load() || notification_->notification_->new_data.load(); }); - - lock.unlock(); } catch (const boost::interprocess::interprocess_exception& /*e*/) {