2 @c @node POSIX Threads, , Cryptographic Functions, Top
4 @c %MENU% POSIX Threads
7 This chapter describes the @glibcadj{} POSIX Thread implementation.
10 * Thread-specific Data:: Support for creating and
11 managing thread-specific data
14 @node Thread-specific Data
15 @section Thread-specific Data
17 The @glibcadj{} implements functions to allow users to create and manage
18 data specific to a thread. Such data may be destroyed at thread exit,
19 if a destructor is provided. The following functions are defined:
23 @item int pthread_key_create (pthread_key_t *@var{key}, void (*@var{destructor})(void*))
24 Create a thread-specific data key for the calling thread, referenced by
27 Objects declared with the C++11 @code{thread_local} keyword are destroyed
28 before thread-specific data, so they should not be used in thread-specific
29 data destructors or even as members of the thread-specific data, since the
30 latter is passed as an argument to the destructor function.
32 @item int pthread_key_delete (pthread_key_t @var{key})
33 Destroy the thread-specific data @var{key} in the calling thread. The
34 destructor for the thread-specific data is not called during destruction, nor
35 is it called during thread exit.
37 @item void *pthread_getspecific (pthread_key_t @var{key})
38 Return the thread-specific data associated with @var{key} in the calling
41 @item int pthread_setspecific (pthread_key_t @var{key}, const void *@var{value})
42 Associate the thread-specific @var{value} with @var{key} in the calling thread.