2 .\" This file and its contents are supplied under the terms of the
3 .\" Common Development and Distribution License ("CDDL"), version 1.0.
4 .\" You may only use this file in accordance with the terms of version
7 .\" A full copy of the text of the CDDL should have accompanied this
8 .\" source. A copy of the CDDL is also available via the Internet at
9 .\" http://www.illumos.org/license/CDDL.
12 .\" Copyright 2016 Joyent, Inc.
23 .Nd thread-specific storage
26 .Vt "typedef void (*tss_dtor_t)(void *);"
48 family of functions create, get, set, and destroy thread-specific
50 .Ss Creating and Destorying Thread-Specific Storage
53 function creates a new thread-specific data key. The key space is opaque
54 and global to all threads in the process. Each thread has its own
55 value-space which can be mainpulated with the
59 functions. A given key persists until
63 When a key is created, the value
65 is associated with all current threads. When a thread is created, the
68 is assigned as the value for the entire key-space.
70 A key may optionally be created with a destructor function
74 will run when the thread exits (see
76 if the value for the key is not
78 The key space's destructors may be run in any order. When the destructor
79 is run due to a thread exiting, all signals will be blocked.
83 function deletes the key identify by
85 from the global name-space. When a key is deleted, no registered
86 destructor is called, it is up to the calling program to free any
87 storage that was associated with
89 across all threads. Because of this propety, it is legal to call
91 from inside a destructor. Any destructors that had been assocaited with
93 will no longer be called when a thread terminates.
97 function may be used to obtain the value associated with
99 for the calling thread. Note that if the calling thread has never set a
100 value, then it will receive the default value,
103 may be called from a tss destructor.
107 function sets the value of the key
109 for the callling thread to
111 which may be obtained by subsequent calls to
113 To remove a value for a specific thread, one may pass
117 Changing the value of a key with
119 does not cause any destructors to be invoked. This means that
121 may be used in the context of a destructor, but special care must be
122 taken to avoid leaking storage or causing an infinite loop.
124 Upon successful completion, the
130 Otherwise, they return
132 to indicate that an error occurred.
134 Upon successful completion, the
136 function returns the thread-specific value associated with the given
138 If no thread-specific value is associated with the key or an invalid key
142 .Sh INTERFACE STABILITY
147 .Xr pthread_getspecific 3C ,
148 .Xr pthread_key_create 3C ,
149 .Xr pthread_key_delete 3C ,
150 .Xr pthread_setspecific 3C ,