pthread_setspecific()

assign thread-specific data to key 

Function


SYNOPSIS

#include <pthread.h>

int pthread_setspecific(pthread_key_t key, const void *value);


DESCRIPTION

The pthread_setspecific() function associates a thread-specific data value with a key obtained via a previous call to pthread_key_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 pthread_setspecific() with a key value not obtained from pthread_key_create() or after the key has been deleted with pthread_key_delete() is undefined.


PARAMETERS

key 

Is the thread-specific data key to which data is assigned.

value 

Is the thread-specific data value to store.


RETURN VALUES

On success, pthread_setspecific() returns 0. On error, one of the following values is returned:

EINVAL 

key is not a valid thread-specific data key.

ENOMEM 

Insufficient memory exists to associate the value with the key.


CONFORMANCE

POSIX P1003.1 (1996)


MULTITHREAD SAFETY LEVEL

MT-safe.


PORTING ISSUES

None.


AVAILABILITY

PTC MKS Toolkit for Professional Developers
PTC MKS Toolkit for Professional Developers 64-Bit Edition
PTC MKS Toolkit for Enterprise Developers
PTC MKS Toolkit for Enterprise Developers 64-Bit Edition


SEE ALSO

Functions:
pthread_getspecific(), pthread_key_create(), pthread_key_delete()


PTC MKS Toolkit 10.4 Documentation Build 39.