Description
"incrementProperty
" is an atomic operation in ElectricCommander. At this time, it is the only property operation that is atomic. If you need to do something more complex, but do it safely in a controlled environment under Commander, there are two implementation methods:
Solution
Use a property as a "token" or "mutex"
-
Initialize it to "
0
" -
Increment it using
incrementProperty
-
If the value is "
1
", hold the token, otherwise, delay and try again -
Do your "protected" operation
-
Set the property to "
0
" -
Be careful if this spans multiple jobs because your job could be aborted while you hold the token.
Use a special resource as a mutex
-
Define a resource (on an existing agent) to use for this purpose
-
Set the resource step limit to "
1
" -
Whenever you need to do a protected operation, set the step to use this resource