pthread_once

Dynamically initializes a once_control.

Library:LibC
Classification:POSIX
Service:Threads

Syntax

  #include <pthread.h>
  
  typedef int   pthread_once_t;
  
  int   pthread_once (
     pthread_once_t   *once_control,
     void             (*init_routine)(void));
  

Parameters

once_control

(IN) Points to a once_control object.

init_routine

(IN) Points to function that initializes the once_control.

Return Values

If successful, returns 0; otherwise, returns a nonzero error code:

Decimal

Constant

Description

9

EINVAL

Either the once_control or the init_routine parameter is invalid.

Remarks

The first thread in a process to call pthread_once initializes the once_control. Subsequent calls do not call the init_routine and have no affect.