pthread_once.h

Singletons features / single-shot execution.

Note

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

PTHREAD_ONCE_INIT

Initialization for pthread_once_t.

1
0

A zeroed out pthread_once_t is initialized.

int pthread_once_t

Datatype to supply to pthread_once.h::pthread_once().

int pthread_once(pthread_once.h::pthread_once_t * once_control, void(*)(void) init_routine)

Helper function that ensures that init_routine is called at once.

Calling pthread_once.h::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.h::PTHREAD_ONCE_INIT or zeroed out.

Parameters

once_control:Flag to ensure that the init_routine is called only once.
init_routine:Function to call if once_control was not used, yet.

Return values

  • 0, this invocation cannot fail.