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.
54 The key space is opaque and global to all threads in the process.
55 Each thread has its own value-space which can be manipulated with the
60 A given key persists until
64 When a key is created, the value
66 is associated with all current threads.
67 When a thread is created, the value
69 is assigned as the value for the entire key-space.
71 A key may optionally be created with a destructor function
75 will run when the thread exits (see
77 if the value for the key is not
79 The key space's destructors may be run in any order.
80 When the destructor is run due to a thread exiting, all signals will be blocked.
84 function deletes the key identify by
86 from the global name-space.
87 When a key is deleted, no registered destructor is called, it is up to the
88 calling program to free any storage that was associated with
91 Because of this propety, it is legal to call
93 from inside a destructor.
94 Any destructors that had been assocaited with
96 will no longer be called when a thread terminates.
100 function may be used to obtain the value associated with
102 for the calling thread.
103 Note that if the calling thread has never set a value, then it will receive the
107 may be called from a tss destructor.
111 function sets the value of the key
113 for the callling thread to
115 which may be obtained by subsequent calls to
117 To remove a value for a specific thread, one may pass
121 Changing the value of a key with
123 does not cause any destructors to be invoked.
126 may be used in the context of a destructor, but special care must be
127 taken to avoid leaking storage or causing an infinite loop.
129 Upon successful completion, the
135 Otherwise, they return
137 to indicate that an error occurred.
139 Upon successful completion, the
141 function returns the thread-specific value associated with the given
143 If no thread-specific value is associated with the key or an invalid key
147 .Sh INTERFACE STABILITY
152 .Xr pthread_getspecific 3C ,
153 .Xr pthread_key_create 3C ,
154 .Xr pthread_key_delete 3C ,
155 .Xr pthread_setspecific 3C ,