93 lines
2.0 KiB
Plaintext
93 lines
2.0 KiB
Plaintext
'\"macro stdmacro
|
|
.\"
|
|
.\" ----------------
|
|
.TH pthread_key_create 3P
|
|
.\"
|
|
.\" ----------------
|
|
.SH NAME
|
|
pthread_key_create \- thread-specific data key creation
|
|
.\"
|
|
.\" ----------------
|
|
.Op c p a
|
|
.SH C SYNOPSIS
|
|
.nf
|
|
.ft 3
|
|
#include <pthread.h>
|
|
.sp .8v
|
|
int pthread_key_create(pthread_key_t *key, void (*destructor)(void *));
|
|
.ft 1
|
|
.fi
|
|
.Op
|
|
.\"
|
|
.\" ----------------
|
|
.SH DESCRIPTION
|
|
The
|
|
.IR pthread_key_create ()
|
|
function creates a key that can be used by all threads in the process to
|
|
get and set thread-specific data. The newly created key is returned in the
|
|
memory pointed to by
|
|
.IR key .
|
|
.PP
|
|
After a new key is created, all active threads have the value
|
|
.B NULL
|
|
associated with that key. After a new thread is created, the value
|
|
.B NULL
|
|
is associated with all keys for that thread.
|
|
.PP
|
|
An optional
|
|
.I destructor
|
|
function may be associated with each key. Upon thread exit [see
|
|
.IR pthread_exit ()],
|
|
if a key has a
|
|
.RB non- NULL
|
|
.I destructor
|
|
pointer and has a
|
|
.RB non- NULL
|
|
value associated with that key, then the
|
|
.I destructor
|
|
function will be called
|
|
with the associated value. The order of
|
|
.I destructor
|
|
calls is unspecified.
|
|
.PP
|
|
If, after the
|
|
.I destructor
|
|
functions have been called for all
|
|
.RB non- NULL
|
|
key values with associated
|
|
.I destructor
|
|
functions, there are still some
|
|
.RB non- NULL
|
|
key values with associated
|
|
.I destructor
|
|
functions, then the process will be repeated. This loop will continue
|
|
until no
|
|
.RB non- NULL
|
|
key values with associated
|
|
.I destructor
|
|
functions exist.
|
|
.\"
|
|
.\" ----------------
|
|
.SH DIAGNOSTICS
|
|
On success,
|
|
.IR pthread_key_create ()
|
|
returns zero; otherwise, an error number is returned:
|
|
.\"
|
|
.TP 15
|
|
.B [EAGAIN]
|
|
The limit on the total number of keys per process has been exceeded [see
|
|
.BR NOTES ].
|
|
.\"
|
|
.\" ----------------
|
|
.SH "SEE ALSO"
|
|
pthread_setspecific(3P), pthread_getspecific(3P), pthread_key_delete(3P),
|
|
pthread_exit(3P), sysconf(3C).
|
|
.\"
|
|
.\" ----------------
|
|
.SH NOTES
|
|
The key limit can be obtained from
|
|
.IR sysconf ()
|
|
using the
|
|
.B THREAD_KEYS_MAX
|
|
option.
|