Thread Safe Variable Class Help
This class contains functions you can use to create, access, and destroy thread safe variablesthread safe variables. Use a thread safe variable to store information that must be accessed from more than one thread. The thread safe variable serializes access to the value from different threads. This prevents more than one thread from changing the value at the same time. If you use an unprotected global variable instead of a thread safe variable, and multiple threads change the value of the unprotected variable at the same time, the variable might have unexpected or incorrect values.
A thread safe variable can be any data type. Pass the size of the data to CmtNewTSV. This allows the Utility Library to allocate the appropriate amount of space for the variable. Access the variable through a void pointer (void *) that you obtain from CmtGetTSVPtr.
It is difficult to program with these functions directly. LabWindows/CVI provides the following macros to simplify using thread safe variables:
- DefineThreadSafeScalarVar
- DefineThreadSafeArrayVar
- DeclareThreadSafeScalarVar
- DeclareThreadSafeArrayVar
These macros are defined in utility.h.
Library: Utility Library