Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 9 additions & 5 deletions MMCore/MMCore.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7769,7 +7769,7 @@ void CMMCore::registerCallback(MMEventCallback* cb) MMCORE_LEGACY_THROW(CMMError
if (cb) {
if (!notificationQueue_) {
auto queue = std::make_shared<mmi::NotificationQueue>();
std::unique_lock<std::shared_mutex> lock(notificationQueueMutex_);
std::lock_guard<std::mutex> lock(notificationQueueMutex_);
notificationQueue_ = queue;
}

Expand All @@ -7786,17 +7786,21 @@ void CMMCore::registerCallback(MMEventCallback* cb) MMCORE_LEGACY_THROW(CMMError
}
});
} else {
std::unique_lock<std::shared_mutex> lock(notificationQueueMutex_);
std::lock_guard<std::mutex> lock(notificationQueueMutex_);
notificationQueue_.reset();
}
}


void CMMCore::postNotification(mmi::Notification notification)
{
std::shared_lock<std::shared_mutex> lock(notificationQueueMutex_);
if (notificationQueue_)
notificationQueue_->Push(std::move(notification));
std::shared_ptr<mmi::NotificationQueue> q;
{
std::lock_guard<std::mutex> lock(notificationQueueMutex_);
q = notificationQueue_;
}
if (q)
q->Push(std::move(notification));
}


Expand Down
3 changes: 1 addition & 2 deletions MMCore/MMCore.h
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,6 @@
#include <map>
#include <memory>
#include <mutex>
#include <shared_mutex>
#include <string>
#include <thread>
#include <vector>
Expand Down Expand Up @@ -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<mmcore::internal::NotificationQueue>
notificationQueue_;
std::thread notificationDeliveryThread_;
Expand Down
Loading