MCPcopy Create free account
hub / github.com/RT-Thread/rt-thread / pthread_setcancelstate

Function pthread_setcancelstate

components/libc/posix/pthreads/pthread.c:1311–1331  ·  view source on GitHub ↗

* @brief Sets the cancelability state of the calling thread. * * The `pthread_setcancelstate` function allows a thread to enable or disable its ability to be canceled * by another thread. Cancelability determines if and when a thread responds to a cancellation request. * * @param[in] state * The new cancelability state for the calling thread. Possible values: * - `PTHREAD_CANCEL_ENABLE`

Source from the content-addressed store, hash-verified

1309 * @see pthread_cancel, pthread_setcanceltype
1310 */
1311int pthread_setcancelstate(int state, int *oldstate)
1312{
1313 _pthread_data_t *ptd;
1314
1315 if (rt_thread_self() == NULL) return EINVAL;
1316
1317 /* get pthread data from pthread_data of thread */
1318 ptd = (_pthread_data_t *)rt_thread_self()->pthread_data;
1319 RT_ASSERT(ptd != RT_NULL);
1320
1321 if ((state == PTHREAD_CANCEL_ENABLE) || (state == PTHREAD_CANCEL_DISABLE))
1322 {
1323 if (oldstate)
1324 *oldstate = ptd->cancelstate;
1325 ptd->cancelstate = state;
1326
1327 return 0;
1328 }
1329
1330 return EINVAL;
1331}
1332RTM_EXPORT(pthread_setcancelstate);
1333
1334/**

Callers 1

searchFunction · 0.85

Calls 1

rt_thread_selfFunction · 0.85

Tested by

no test coverage detected