chsvlib
chsv helper source code

◆ chsv_tss_get()

void* Chusov::ExecutionControl::chsv_tss_get ( chsv_tss_t  key)
noexcept

Returns the value for the current thread held in the thread-specific storage (TSS) identified by the specified key.

Parameters
[in]keyis an identifier of the TSS associated with thread-specific data pointed to by the returned value
Returns
On success the function the function returns a pointer to the thread-specific storage, which can be NULL. On error the function always return NULL and sets the corresponding errno code. Setting errno to 0 before the call and checking it after the call can identify the failure.

The function returns the value currently bound to the specified key on behalf of the calling thread.

The chsv_tss_set function associates a thread-specific value with a key obtained via a previous call to chsv_tss_create. Different threads may bind different values to the same key. These values are typically pointers to blocks of dynamically allocated memory that have been reserved for use by the calling thread.

The effect of calling chsv_tss_get or chsv_tss_set with a key value not obtained from pthread_key_create or after key has been deleted with chsv_tss_delete is leads to a failure.

Both chsv_tss_get and chsv_tss_set may be called from a thread-specific data destructor function. A call to chsv_tss_get for the thread-specific data key being destroyed will return the value NULL, unless the value is changed (after the destructor starts) by a call to chsv_tss_set. Calling chsv_tss_set from a thread-specific data destructor routine may result in lost storage after at least CHSV_TSS_DTOR_ITERATIONS attempts at destruction.

The function implements a behaviour of the tss_get function defined in the ISO/IEC 9899:2011 (aka C11) standard.

See also
chsv_tss_create;
chsv_tss_delete;
chsv_tss_set.