From n3220, 7.28.2.1, The call_once
function
Synopsis
#include <threads.h>
void call_once(once_flag *flag, void (*func)(void));
Description
The
call_once
function uses the
once_flag
pointed to by flag to ensure thatfunc
is called exactly
once, the first time thecall_once
function is called with that value
offlag
. Completion of an effective call to thecall_once
function
synchronizes with all subsequent calls to thecall_once
function with
the same value of flag.Returns
The
call_once
function returns no value.
From what it sounds like, is this supposed to be used for init()
/config()
functions that are only supposed to be called once? Or am I completely misunderstanding it and it is something pertinent to threads?
What is this useful for? What is flag
, and how is it relevant here?
5