-
Notifications
You must be signed in to change notification settings - Fork 111
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
10 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -1307,15 +1307,17 @@ void CDemoCamera::SlowPropUpdate() | |
// in a thread | ||
long delay; GetProperty("AsyncPropertyDelayMS", delay); | ||
CDeviceUtils::SleepMs(delay); | ||
MMThreadGuard g(asyncFollowerLock_); | ||
asyncFollower = asyncLeader; | ||
{ | ||
MMThreadGuard g(asyncFollowerLock_); | ||
asyncFollower = asyncLeader; | ||
} | ||
OnPropertyChanged("AsyncPropertyFollower", asyncFollower.c_str()); | ||
This comment has been minimized.
Sorry, something went wrong.
This comment has been minimized.
Sorry, something went wrong.
ianhi
Author
Contributor
|
||
} | ||
|
||
int CDemoCamera::OnAsyncFollower(MM::PropertyBase* pProp, MM::ActionType eAct) | ||
{ | ||
MMThreadGuard g(asyncFollowerLock_); | ||
if (eAct == MM::BeforeGet){ | ||
MMThreadGuard g(asyncFollowerLock_); | ||
pProp->Set(asyncFollower.c_str()); | ||
} | ||
// no AfterSet as this is a readonly property | ||
|
@@ -1324,13 +1326,16 @@ 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){ | ||
MMThreadGuard g(asyncLeaderLock_); | ||
This comment has been minimized.
Sorry, something went wrong.
marktsuchida
Member
|
||
pProp->Set(asyncLeader.c_str()); | ||
} | ||
if (eAct == MM::AfterSet) | ||
{ | ||
pProp->Get(asyncLeader); | ||
{ | ||
MMThreadGuard g(asyncLeaderLock_); | ||
pProp->Get(asyncLeader); | ||
} | ||
fut_ = std::async(std::launch::async, &CDemoCamera::SlowPropUpdate, this); | ||
} | ||
return DEVICE_OK; | ||
|
You need to copy
asyncFollower
(which should beasyncFollower_
, BTW) to a temporary local variable while holding the mutex.