*** UNIX MANUAL PAGE BROWSER ***

A Nergahak database for man pages research.

Navigation

Directory Browser

1Browse 4.4BSD4.4BSD
1Browse Digital UNIXDigital UNIX 4.0e
1Browse FreeBSDFreeBSD 14.3
1Browse MINIXMINIX 3.4.0rc6-d5e4fc0
1Browse NetBSDNetBSD 10.1
1Browse OpenBSDOpenBSD 7.7
1Browse UNIX v7Version 7 UNIX
1Browse UNIX v10Version 10 UNIX

Manual Page Search

Manual Page Result

0 Command: ONCE_FLAG_INIT | Section: 3 | Source: NetBSD | File: ONCE_FLAG_INIT.3
CALL_ONCE(3) FreeBSD Library Functions Manual CALL_ONCE(3) NAME call_once - calls function exactly once LIBRARY POSIX Threads Library (libpthread, -lpthread) SYNOPSIS #include <threads.h> void call_once(once_flag *flag, void (*func)(void)); #define ONCE_FLAG_INIT /* implementation specified */ DESCRIPTION The call_once function uses the flag parameter to ensure that func is called exactly once, even if called from several threads. The ONCE_FLAG_INIT definition expands to a value that can be used to initialize an object of type once_flag. This portable interface is implemented on top of the pthread_once(3) functionality. RETURN VALUES None. EXAMPLES The following calls call_once from two threads using the portable thrd(3) interface. #include <stdio.h> #include <threads.h> static once_flag oflag = ONCE_FLAG_INIT; void called_once(void) { printf("called once0); } int tfun(void *ptr) { call_once(&oflag, called_once); } int main(int argc, char **argv) { thrd_t th1, th2; thrd_create(&th1, tfun, NULL); thrd_create(&th2, tfun, NULL); thrd_join(th1, NULL); thrd_join(th2, NULL); return 0; } SEE ALSO pthread_once(3), threads(3) STANDARDS The call_once function conforms to ISO/IEC 9899:2011 ("ISO C11"). HISTORY This interface first appeared in NetBSD 9. AUTHORS Kamil Rytarowski <[email protected]> FreeBSD 14.1-RELEASE-p8 October 16, 2016 FreeBSD 14.1-RELEASE-p8

Navigation Options