pthread_once.h File Reference

Singletons features / single-shot execution. More...

Detailed Description

Note
Do not include this header file directly, but pthread.h.

Definition in file pthread_once.h.

+ This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

#define PTHREAD_ONCE_INIT   0
 Initialization for pthread_once_t. More...
 
typedef volatile int pthread_once_t
 Datatype to supply to pthread_once().
 
int pthread_once (pthread_once_t *once_control, void(*init_routine)(void))
 Helper function that ensures that init_routine is called at once. More...
 

Macro Definition Documentation

◆ PTHREAD_ONCE_INIT

#define PTHREAD_ONCE_INIT   0

A zeroed out pthread_once_t is initialized.

Definition at line 34 of file pthread_once.h.

Function Documentation

◆ pthread_once()

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

Calling pthread_once() changes once_control. For the same once_control the supplied init_routine won't get called again, unless once_control is reset to PTHREAD_ONCE_INIT or zeroed out.

Parameters
[in,out]once_controlFlag to ensure that the init_routine is called only once.
[in]init_routineFunction to call if once_control was not used, yet.
Returns
0, this invocation cannot fail.