LabWindows/CVI

Content Type
Programming Language
Current manual

CmtDiscardThreadLocalVar

CmtDiscardThreadLocalVar

int CmtDiscardThreadLocalVar (CmtTLVHandle variableHandle);

Purpose

Destroys a thread local variable and frees the resources used by it.

After you call this function, you can no longer access the thread local variable from any thread.

This function calls the discardCallbackFunction parameter, which you specified in CmtNewThreadLocalVar, once for each thread that accessed the thread local variable. Note that CmtDiscardThreadLocalVar calls the callback in the thread that calls CmtDiscardThreadLocalVar, and not in the individual threads that accessed the thread local variable. Therefore, if you use the thread local variable to store a resource that must be freed from the thread that created it, you must use PostDeferredCallToThread to notify the proper thread that it must clean up the resource.

Parameters

Input
Name Type Description
variableHandle CmtTLVHandle The handle you obtained from CmtNewThreadLocalVar to identify the thread local variable.

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

Examples

Refer to the following examples that use the CmtDiscardThreadLocalVar function:

  • utility\threading\ThreadLocalVar\ThreadLocalVar.cws

    Open example
  • utility\threading\ThreadPool\OnePanel\OnePanel.cws

    Open example
Was this information helpful?