Skip to content

Commit

Permalink
add locks to async leader/follower props
Browse files Browse the repository at this point in the history
  • Loading branch information
ianhi committed Feb 24, 2022
1 parent 8d2d871 commit 9c39070
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 0 deletions.
3 changes: 3 additions & 0 deletions DeviceAdapters/DemoCamera/DemoCamera.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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());
}
Expand All @@ -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());
}
Expand Down
2 changes: 2 additions & 0 deletions DeviceAdapters/DemoCamera/DemoCamera.h
Original file line number Diff line number Diff line change
Expand Up @@ -272,6 +272,8 @@ class CDemoCamera : public CCameraBase<CDemoCamera>
std::string asyncLeader;
std::string asyncFollower;
MMThreadLock imgPixelsLock_;
MMThreadLock asyncLeaderLock_;
MMThreadLock asyncFollowerLock_;
friend class MySequenceThread;
int nComponents_;
MySequenceThread * thd_;
Expand Down

0 comments on commit 9c39070

Please sign in to comment.