call_once(3) | Library Functions Manual | call_once(3) |
NAME
call_once
— call
function only from a single thread, once
SYNOPSIS
library “threads”
#include <threads.h>
once_flag once =
ONCE_FLAG_INIT;
void
call_once
(once_flag
*flag, void
(*fn)());
DESCRIPTION
The
call_once
()
function calls the given callback function fn exactly
once even when called from multiple threads at the same time. This is done
by setting the given flag atomically upon entry to the
function. The flag must be initialized to
ONCE_FLAG_INIT
before calling
call_once
().
HISTORY
The call_once
() function first appeared in
the C11 standard ISO/IEC 9899:2011.
AUTHORS
Jan Adelsbach <jan@jadelsbach.de>
Debian |