📄 pthread_cleanup_push.txt
字号:
pthread_cleanup_push SubroutinePurposePushes a routine onto the calling thread's cleanup stack.LibraryThreads Library (libpthreads.a)Syntax#include <pthread.h>void pthread_cleanup_push (routine, arg)void (*routine) (void *);void *arg;DescriptionThe pthread_cleanup_push subroutine pushes the routine routine ontothe calling thread's cleanup stack.The cleanup stack is an ordinary LIFO routines stack, used for performingall necessary cleanups at thread termination. The stacked cleanuproutines are executed when the thread terminates or when it is canceled.When the entire process is terminated, due to a signal or to a callto either the exec, exit, or fork subroutines, the cleanup routinesare not called.The cleanup routines are called with the arg parameter as the singleparameter. It is a void pointer; it can reference any kind of data.It is not recommended to cast this pointer into a scalar data type(int for example), because the casts may not be portable.For each call to the pthread_cleanup_push subroutine, there shouldbe a call to the pthread_cleanup_pop subroutine in the same functionand in the same block of statement. Otherwise, the compiler may failcompiling the program, or the program would have an unpredictablebehaviour when porting to other systems. The reason is that, on non-AIXsystems, the pthread_cleanup_push subroutine may be implemented asa macro opening a block of statements.Note: The pthread.h header file must be the first included file ofeach source file using the threads library.Parametersroutine Points to the cleanup routine.arg Points to the single argument to be passed to the cleanup routine.Implementation SpecificsThis subroutine is part of the Base Operating System (BOS) Runtime.Related InformationThe pthread_cleanup_pop subroutine, pthread_exit subroutine.Terminating Threads.Threads Library Quick Reference.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -