Name

NAME

pthread_setcancelstate, pthread_setcanceltype, pthread_testcancel_set cancelability state

SYNOPSIS

THR # include <pthread.h>

    int pthread_setcancelstate (int state, int *oldstate);
    int pthread_setcanceltype (into type, int *oldtype);
    void pthread_testcancel (void);

DESCRIPTION

The pthread_setcancelstate() function shall atomically both set the calling thread's cancelability state to the indicated stateand return the previous cancelability state at the location referenced by oldstate. Legal values for state are PTHREAD_CANCEL_ENABLE and PTHREAD_CANCEL_DISABLE.

The pthread_setcanceltype() function shall atomically both set the calling thread's cancelability type to the indicated type and return the previous cancelability type at the location referenced by oldtype. Legal values for type are PTHREAD_CANCEL_DEFERRED and PTHREAD_CANCEL_ASYNCHRONOUS.

The cancelability state and type of any newly created threads, including the thread in which main() was first invoked, shall be PTHREAD_CANCEL_ENABLE and PTHREAD_CANCEL_DEFERRED respectively.

The pthread_testcancel() function shall create a cancelation point in the calling thread. The pthread_testcancel() function shall no effect if cancelability is disabled.

RETURN VALUE

If successful, the pthread_setcancelstate() and pthread_setcanceltype() functions shall return zero;otherwise, an error number shall be returned to indicate the error.

ERRORS

The pthread_setcancelstate() function may fail if:

[EINVAL]

The specified state is not PTHREAD_CANCEL_ENABLE ...

Get Professional Multicore Programming: Design and Implementation for C++ Developers now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.