pthread_once.txt

来自「Pthread lib库完整说明文档」· 文本 代码 · 共 73 行

TXT
73
字号
           --------------------------------------------------------------------------------AIX Version 4.3 Base Operating System and Extensions Technical Reference, Volume                                       1--------------------------------------------------------------------------------pthread_once SubroutinePurposeExecutes a routine exactly once in a process.LibraryThreads Library (libpthreads.a)Syntax#include <pthread.h>int pthread_once (pthread_once_t *once_control, void (*init_routine)(void));pthread_once_t once_control = PTHREAD_ONCE_INIT;DescriptionThe pthread_once subroutine executes the routine init_routine exactly once in aprocess. The first call to this subroutine by any thread in the process executesthe given routine, without parameters. Any subsequent call will have no effect.The init_routine routine is typically an initialization routine. Multipleinitializations can be handled by multiple instances of pthread_once_tstructures. This subroutine is useful when a unique initialization has to be doneby one thread among many. It reduces synchronization requirements.    Note: The pthread.h header file must be the first included file of each    source file using the threads library. Otherwise, the -D_THREAD_SAFE    compilation flag should be used, or the cc_r compiler used. In this case, the    flag is automatically set.Parametersonce_block Points to a synchronization control structure. This structure has tobe initialized by the static initializer macro PTHREAD_ONCE_INIT.init_routine Points to the routine to be executed.Return ValuesUpon successful completion, pthread_once returns zero. Otherwise, an error numberis returned to indicate the error.Error CodesNo errors are defined. The pthread_once function will not return an error code ofEINTR.Implementation SpecificsThis subroutine is part of the Base Operating System (BOS) Runtime.Related InformationThe pthread_create subroutine, pthread.h file, PTHREAD_ONCE_INIT macro.One Time Initializations in AIX Version 4.3 General Programming Concepts: Writingand Debugging Programs.Threads Library Quick Reference in AIX Version 4.3 General Programming Concepts:Writing and Debugging Programs.--------------------------------------------------------------------------------           

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?