1 .TH PTHREAD_ONCE 3 LinuxThreads
4 pthread_once \- once-only initialization
7 .B #include <pthread.h>
9 .BI "pthread_once_t " once_control " = PTHREAD_ONCE_INIT;"
11 .BI "int pthread_once(pthread_once_t *" once_control ", void (*" init_routine ") (void));"
15 The purpose of \fBpthread_once\fP is to ensure that a piece of
16 initialization code is executed at most once. The \fIonce_control\fP
17 argument points to a static or extern variable statically initialized
18 to \fBPTHREAD_ONCE_INIT\fP.
20 The first time \fBpthread_once\fP is called with a given \fIonce_control\fP
21 argument, it calls \fIinit_routine\fP with no argument and changes the
22 value of the \fIonce_control\fP variable to record that initialization has
23 been performed. Subsequent calls to \fBpthread_once\fP with the same
24 \fBonce_control\fP argument do nothing.
27 \fBpthread_once\fP always returns 0.
33 Xavier Leroy <Xavier.Leroy@inria.fr>