Loading...
Searching...
No Matches
pthread_once.h File Reference

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

Detailed Description

Singletons features / single-shot execution.

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.

Data Structures

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

Macro Definition Documentation

◆ PTHREAD_ONCE_INIT

#define PTHREAD_ONCE_INIT   { 1, 0 }

Initialization for pthread_once_t.

pthread_once_t variables are declared as initialized, but the init function is not yet executed.

Definition at line 40 of file pthread_once.h.

Function Documentation

◆ pthread_once()

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

Helper function that ensures that init_routine is called at once.

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.