diff --git a/MMCore/MMCore.cpp b/MMCore/MMCore.cpp index c6c9f438f..476debf2e 100644 --- a/MMCore/MMCore.cpp +++ b/MMCore/MMCore.cpp @@ -7769,7 +7769,7 @@ void CMMCore::registerCallback(MMEventCallback* cb) MMCORE_LEGACY_THROW(CMMError if (cb) { if (!notificationQueue_) { auto queue = std::make_shared(); - std::unique_lock lock(notificationQueueMutex_); + std::lock_guard lock(notificationQueueMutex_); notificationQueue_ = queue; } @@ -7786,7 +7786,7 @@ void CMMCore::registerCallback(MMEventCallback* cb) MMCORE_LEGACY_THROW(CMMError } }); } else { - std::unique_lock lock(notificationQueueMutex_); + std::lock_guard lock(notificationQueueMutex_); notificationQueue_.reset(); } } @@ -7794,9 +7794,13 @@ void CMMCore::registerCallback(MMEventCallback* cb) MMCORE_LEGACY_THROW(CMMError void CMMCore::postNotification(mmi::Notification notification) { - std::shared_lock lock(notificationQueueMutex_); - if (notificationQueue_) - notificationQueue_->Push(std::move(notification)); + std::shared_ptr q; + { + std::lock_guard lock(notificationQueueMutex_); + q = notificationQueue_; + } + if (q) + q->Push(std::move(notification)); } diff --git a/MMCore/MMCore.h b/MMCore/MMCore.h index d032441a8..a8a57947d 100644 --- a/MMCore/MMCore.h +++ b/MMCore/MMCore.h @@ -62,7 +62,6 @@ #include #include #include -#include #include #include #include @@ -738,7 +737,7 @@ class CMMCore bool isLoadingSystemConfiguration_ = false; std::mutex callbackMutex_; // Serializes registerCallback() calls - std::shared_mutex notificationQueueMutex_; // Protects notificationQueue_ + std::mutex notificationQueueMutex_; // Protects notificationQueue_ std::shared_ptr notificationQueue_; std::thread notificationDeliveryThread_;