Query: pthread_once
OS: hpux
Section: 3t
Format: Original Unix Latex Style Formatted with HTML and a Horizontal Scroll Bar
pthread_once(3T) pthread_once(3T)NAMEpthread_once() - call an initialization routine only onceSYNOPSISParameters once_control Pointer to the once-control object associated with the one-time initialization function init_routine The one-time initialization routine. This routine is called only once, regardless of the number of times it and its associ- ated once_control are passed toDESCRIPTIONThe function guarantees that is only called one time in an application. This function will use the once_control object to determine if has previously been called via The first time is called with once_control and causes to be called with no arguments. Subsequent calls to with the same once_control will not cause to be called again. When returns, the caller is guaranteed that has been called (either just now or via a previous call). The macro is used to statically initialize a once control block. This initialization must be done before calling is not a cancellation point. However, the caller supplied may be a cancellation point. If the thread executing is canceled, the once_con- trol argument will be set to a state which indicates that has not been called yet (see pthread_cancel(3T)). The next time the function is called with once_control, the function will be called. The behavior of is undefined if once_control has automatic storage duration or is not initialized byRETURN VALUEreturns returns the following values: Successful completion. Failure. An error number is returned to indicate the error. (The variable is not set.)ERRORSThe following error value is returned by if the corresponding condition is detected. Either once_control or init_routine is invalid.EXAMPLESSome modules are designed for dynamic initialization, i.e., global initialization is performed when the first function of the module is invoked. In a single-threaded program, this is generally implemented as follows: (Rest of the code after initialization.) For a multithreaded process, a simple initialization flag is not sufficient; the flag must be protected against modification by multiple threads. Consequently, this flag has to be protected by a mutex that has to be initialized only once, and so on. A multithreaded program should use initialization similar to: (Rest of the code after initialization.)AUTHORwas derived from the IEEE POSIX P1003.1c standard.SEE ALSOpthread_create(3T).STANDARDS CONFORMANCEPthread Library pthread_once(3T)
Related Man Pages |
---|
pthread_once(3c) - opensolaris |
pthread_once(3) - linux |
pthread_condattr_destroy(3t) - hpux |
pthread_mutex_init(3t) - hpux |
pthread_mutexattr_init(3t) - hpux |
Similar Topics in the Unix Linux Community |
---|
Rest From Social |
[bash] getopts not executing when called second time. |
Rest Assured |