From 9c3907050c747253238ae8c0def1901f10aba457 Mon Sep 17 00:00:00 2001 From: Ian Hunt-Isaak Date: Wed, 23 Feb 2022 23:13:34 -0500 Subject: [PATCH] add locks to async leader/follower props --- DeviceAdapters/DemoCamera/DemoCamera.cpp | 3 +++ DeviceAdapters/DemoCamera/DemoCamera.h | 2 ++ 2 files changed, 5 insertions(+) diff --git a/DeviceAdapters/DemoCamera/DemoCamera.cpp b/DeviceAdapters/DemoCamera/DemoCamera.cpp index 284a66189..7f53a4fa6 100644 --- a/DeviceAdapters/DemoCamera/DemoCamera.cpp +++ b/DeviceAdapters/DemoCamera/DemoCamera.cpp @@ -1307,12 +1307,14 @@ void CDemoCamera::SlowPropUpdate() // in a thread long delay; GetProperty("AsyncPropertyDelayMS", delay); CDeviceUtils::SleepMs(delay); + MMThreadGuard g(asyncFollowerLock_); asyncFollower = asyncLeader; OnPropertyChanged("AsyncPropertyFollower", asyncFollower.c_str()); } int CDemoCamera::OnAsyncFollower(MM::PropertyBase* pProp, MM::ActionType eAct) { + MMThreadGuard g(asyncFollowerLock_); if (eAct == MM::BeforeGet){ pProp->Set(asyncFollower.c_str()); } @@ -1322,6 +1324,7 @@ int CDemoCamera::OnAsyncFollower(MM::PropertyBase* pProp, MM::ActionType eAct) int CDemoCamera::OnAsyncLeader(MM::PropertyBase* pProp, MM::ActionType eAct) { + MMThreadGuard g(asyncLeaderLock_); if (eAct == MM::BeforeGet){ pProp->Set(asyncLeader.c_str()); } diff --git a/DeviceAdapters/DemoCamera/DemoCamera.h b/DeviceAdapters/DemoCamera/DemoCamera.h index af6b7e317..8a6825a75 100644 --- a/DeviceAdapters/DemoCamera/DemoCamera.h +++ b/DeviceAdapters/DemoCamera/DemoCamera.h @@ -272,6 +272,8 @@ class CDemoCamera : public CCameraBase std::string asyncLeader; std::string asyncFollower; MMThreadLock imgPixelsLock_; + MMThreadLock asyncLeaderLock_; + MMThreadLock asyncFollowerLock_; friend class MySequenceThread; int nComponents_; MySequenceThread * thd_;