TlsSetValue
TlsSetValue stores a value in the calling thread's thread local storage (TLS) slot for a specified TLS index. Each thread of a process has its own slot for each TLS index.
Syntax
BOOL TlsSetValue(
[in] DWORD TlsIndex,
[in, optional] LPVOID lpTlsValue
);
Parameters
TlsIndex
The TLS index that was allocated by TlsAlloc.
lpTlsValue
The value to be stored in the calling thread's TLS slot-specified by TlsIndex.
Return Value
If the function succeeds, it returns TRUE. If the function fails, it returns FALSE. Call GetLastError to get extended error information.
Remarks
TlsAlloc typically allocates TLS indexes during the process or DLL initialization. Once allocated, each process thread can use a TLS index to access its own TLS storage slot for that index. The storage slot for each thread is initialized to NULL. A thread specifies a TLS index in a call to TlsSetValue, to store a value in its slot. The thread specifies the same index in a subsequent call to TlsGetValue, to retrieve the stored value.
TlsSetValue and TlsGetValue were implemented with speed as the primary goal. These functions perform minimal parameter validation and error checking. This function succeeds if TlsIndex is in the range 0 through (TLS_MINIMUM_AVAILABLE - 1). It is up to the programmer to ensure that the index is valid.
Requirements
| Minimum supported version | Header | Library |
|---|---|---|
|
wRTOS 1.0 SDK |
windows.h |
wRTOS_rtss.lib |
See Also: