[Previous] [Contents] [Next]

pthread_setspecific()

Set thread specific data value

Synopsis:

#include <pthread.h>

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

Library:

libc

Description:

The pthread_setspecific() function binds the thread specific data value value with the thread specific data key key. The key must have been created by a previous call to pthread_key_create(). This function may be called from within a thread specific data destructor function.

Returns:

EOK
Success.
ENOMEM
Insufficient memory to store thread specific data value value.
EINVAL
Invalid thread specific data key key.

Classification:

POSIX 1003.1 (Threads)

Safety:
Cancellation point No
Interrupt handler No
Signal handler No
Thread Yes

Caveats:

Calling pthread_setspecific() with a non-NULL value may result in lost storage or infinite loops unless value was returned by pthread_key_create().

See also:

pthread_key_create(), pthread_getspecific()


[Previous] [Contents] [Next]