MirBSD manpage: pthread_once(3)

PTHREAD_ONCE(3)            BSD Programmer's Manual             PTHREAD_ONCE(3)


     pthread_once - dynamic package initialization


     #include <pthread.h>

     pthread_once_t once_control = PTHREAD_ONCE_INIT;

     pthread_once(pthread_once_t *once_control, void (*init_routine)(void));


     The first call to pthread_once() by any thread in a process, with a given
     once_control, will call the init_routine() with no arguments. Subsequent
     calls to pthread_once() with the same once_control will not call the
     init_routine(). On return from pthread_once(), it is guaranteed that
     init_routine() has completed. The once_control parameter is used to
     determine whether the associated initialization routine has been called.

     The function pthread_once() is not a cancellation point. However, if
     init_routine() is a cancellation point and is cancelled, the effect on
     once_control is as if pthread_once() was never called.

     The constant PTHREAD_ONCE_INIT is defined in the header file <pthread.h>.

     The behavior of pthread_once() is undefined if once_control has automatic
     storage duration or is not initialized by PTHREAD_ONCE_INIT.


     If successful, the pthread_once() function will return zero. Otherwise an
     error number will be returned to indicate the error.




     pthread_once() conforms to ISO/IEC 9945-1:1996 ("POSIX.1").

MirBSD #10-current              April 4, 1996                                1

Generated on 2022-12-24 01:00:14 by $MirOS: src/scripts/roff2htm,v 1.113 2022/12/21 23:14:31 tg Exp $ — This product includes material provided by mirabilos.

These manual pages and other documentation are copyrighted by their respective writers; their sources are available at the project’s CVSweb, AnonCVS and other mirrors. The rest is Copyright © 2002–2022 MirBSD.

This manual page’s HTML representation is supposed to be valid XHTML/1.1; if not, please send a bug report — diffs preferred.

Kontakt / Impressum & Datenschutzerklärung