call_once Subroutine
Purpose
Runs the function that is specified by the func parameter only once, even if the function is called from several threads.
Library
Standard C library (libc.a)
Syntax
Description
The call_once subroutine uses the once_flag value specified by the flag parameter to ensure that the function specified by the func parameter is called exactly once when the call_once subroutine is called for the first time, with the value of the flag parameter.
An effective call to the call_once subroutine synchronizes all the subsequent calls to the call_once subroutine by using the same value of the flag parameter.
Parameters
Item | Description |
---|---|
flag | Specifies the value of the parameter to call the call_once subroutine and to synchronize all further calls with this flag. |
func | Specifies the function that is called only once. |
Return Values
No return value.
Files
The threads.h file defines standard macros, data types, and subroutines.