使用 pthread_testcancel 作为pthread_cancel 时 线程的退出点函数

来源:互联网 发布:联想yoga11软件 编辑:程序博客网 时间:2024/05/16 13:53

 

pthread_testcancel()--Create Cancellation Point

Syntax 

#include <pthread.h>void pthread_testcancel(void);Threadsafe: YesSignal Safe: No
The pthread_testcancel() function creates a cancellation point in the calling thread. If cancelability is currently disabled, this function has no effect. For more information on cancelability, see Thread cancellation APIs.

When cancelability is disabled, all cancels are held pending in the target thread until the thread changes the cancelability. When cancelability is deferred, all cancels are held pending in the target thread until the thread changes the cancelability, calls a function that is a cancellation point, or calls pthread_testcancel(), thus creating a cancellation point. When cancelability is asynchronous, all cancels are acted upon immediately, interrupting the thread with its processing.

You should not use asynchronous thread cancellation via the PTHREAD_CANCEL_ASYNCHRONOUS option of pthread_setcanceltype(). See the common user errors section of this document for more information.

 

原创粉丝点击