Does anyone really understand the difference between PropFlags_Shared and PropFlags_SharedAtRunTime?
I’m using the PropFlags_Shared for both Locals and for FileGlobals. I was originally using PropFlags_SharedAtRunTime but realized after some time that it was not working correctly.
I have read another forum discussion regarding this however it seems quite old and also didn’t really clarify the issue for me.
Here is a brief description of the File Globals PropFlags_Shared usage:
Without digging incredibly deep into the functionality of those flags, my initial suspicion is that while set to SharedAtRunTime the FileGlobal will be shared between threads only when the sequence starts. After which there is no sharing of the data. When set to Shared, the FileGlobal is shared continuously across threads throughout the sequence execution.
Thank You Mitchell,
Can I assume that "shared between threads only when the sequence starts" essentially means the first time the variable is encountered? E.g. The sequence starts running and at some point down in the code the variable is encountered, that point is where SharedAtRunTime will share across all threads? All future places in the code the variable is not shared and all future batches the variable is not shared. This is how SharedAtRunTime seems to be behaving.
I'd recommend trying to clone a shared object at runtime and observe the difference in behavior between the two flags. For example:
1. Create a Sequence with a numeric FileGlobal "Global1"
2. Run Statement:
3. Observe the difference in behavior when Global1 has the shared vs shared at runtime flag set.
As for your actual use case, you should consider changing the scope of your FileGlobals in the Sequence File Properties instead of using the shared flag.
Hope this helps!
The shared flags apply to when TestStand creates a clone of a property. Note that when the PropOption_DoNotShareProperties option is used with Clone, a shared flag is ignored.
If the original object has a parent property, that parent ownership is maintained, and the parent in the copy contains an alias to the original object.
One main use of shared flags in TestStand is to save memory when TestStand creates runtime copies of sequences, specifically all the properties under Step.TS.
Common examples of when TestStand clones property objects and use of shared flags will affect behavior:
The shared at runtime flag applies only when the TestStand engine makes a runtime copy of a property, such as the runtime copy of a sequence. Performing a "runtime" clone is not exposed via the TestStand API.
Note: TestStand does not clone an object when it does a copy and a paste, it instead does a serialization and a deserialization, so the copy of the property does not have any sharing.