LabWindows/CVI

Content Type
Programming Language
Current manual

CmtSetTSV

CmtSetTSV

int CmtSetTSV (CmtTSVHandle variableHandle, const void *valuePointer);

Purpose

Sets the value of the thread safe variable.

If another thread either has the thread safe variable pointer or is currently setting the value of the thread safe variable, this function waits until the other thread has completed its operation.

Do not use this function if the value you are setting depends on the previous value of this thread safe variable. For example, if you want to increment the value of a thread safe integer variable, it is not valid to call CmtGetTSVPtr to get the value, store the value in a local variable, call CmtReleaseTSVPtr to release the pointer, increment the local variable, and then CmtSetTSV to set the value to the value of the local variable. This is not valid because another thread might change the value between your calls to CmtReleaseTSVPtr and CmtSetTSV, thereby invalidating the incremented value of the variable.

It is difficult to program with this function directly. It is easier to program with the functions provided by the DefineThreadSafeScalarVar, DefineThreadSafeArrayVar, DeclareThreadSafeScalarVar, and DeclareThreadSafeArrayVar macros, which are defined in utility.h.

Parameters

Input
Name Type Description
variableHandle CmtTSVHandle The handle you obtained from CmtNewTSV to identify the thread safe variable.
valuePointer const void * A pointer to a variable that contains the needed value.

Return Value

Name Type Description
cmtStatus int The CmtStatus code that the function call returns. This function returns 0 to indicate success and negative values to indicate failure. Pass the CmtStatus code to CmtGetErrorMessage to get a description of the error code.

Additional Information

Library: Utility Library

Include file: utility.h

LabWindows/CVI compatibility: LabWindows/CVI 5.5 and later

Was this information helpful?