◆ p99_call_once

#define p99_call_once (   FLAG,

Call a function FUNC exactly once, optionally providing it with argument ARG.

This is an extension of the standard function call_once.

  • If ARG is given, it must be compatible with type void* and is passed to FUNC as an argument. In this case FUNC must have the prototype void FUNC(void*).
  • If ARG is omitted FUNC should have the prototype void FUNC(void), i.e not take any argument.
  • If the field p00_init is initialized with an appropriate function, the FUNC can also be omitted and p00_init is then called instead.
The FLAG is only protected by an ::atomic_flag. Therefore the functions that are passed to this should be nice and short.
These functions are protected against recursion and should not deadlock when they are confronted with cyclic dependencies. But obviously, the order in which such a cycle is taken is not predictable.
See also

Definition at line 202 of file p99_threads.h.