线程函数pthread_cleanup_push()

来源:互联网 发布:网络设计工程师 编辑:程序博客网 时间:2024/06/08 15:34

NAME

pthread_cleanup_push, pthread_cleanup_pop - establish cancellation handlers

SYNOPSIS

#include <pthread.h>void pthread_cleanup_push(void (*routine)(void*), void *arg);void pthread_cleanup_pop(int execute);

DESCRIPTION

The pthread_cleanup_push() function pushes the specified cancellation cleanup handlerroutine onto the calling thread's cancellation cleanup stack. The cancellation cleanup handler is popped from the cancellation cleanup stack and invoked with the argumentarg when: (a) the thread exits (that is, calls pthread_exit()), (b) the thread acts upon a cancellation request, or (c) the thread callspthread_cleanup_pop() with a non-zero execute argument.

The pthread_cleanup_pop() function removes the routine at the top of the calling thread's cancellation cleanup stack and optionally invokes it (ifexecute is non-zero).

These functions may be implemented as macros and will appear as statements and in pairs within the same lexical scope (that is, thepthread_cleanup_push() macro may be thought to expand to a token list whose first token is`{' with pthread_cleanup_pop() expanding to a token list whose last token is the corresponding`}'.

The effect of calling longjmp() orsiglongjmp() is undefined if there have been any calls topthread_cleanup_push() or pthread_cleanup_pop() made without the matching call since the jump buffer was filled. The effect of callinglongjmp() orsiglongjmp() from inside a cancellation cleanup handler is also undefined unless the jump buffer was also filled in the cancellation cleanup handler.

RETURN VALUE

The pthread_cleanup_push() and pthread_cleanup_pop() functions return no value.

ERRORS

No errors are defined.

These functions will not return an error code of [EINTR].

EXAMPLES

None.

APPLICATION USAGE

None.

FUTURE DIRECTIONS

None.

SEE ALSO

pthread_cancel(),pthread_setcancelstate(),<pthread.h>.

DERIVATION

Derived from the POSIX Threads Extension (1003.1c-1995)
原创粉丝点击