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

Function pthread_cleanup_pop

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

* @brief Unregisters a cleanup handler and optionally executes it. * * The `pthread_cleanup_pop` function unregisters a cleanup handler that was previously registered * using `pthread_cleanup_push`. If the `execute` parameter is non-zero, the cleanup handler is executed * at the point where the thread terminates or is canceled. * * If `execute` is zero, the handler is unregistered without be

Source from the content-addressed store, hash-verified

1173 * @see pthread_cleanup_push, pthread_exit, pthread_cancel
1174 */
1175void pthread_cleanup_pop(int execute)
1176{
1177 _pthread_data_t *ptd;
1178 _pthread_cleanup_t *cleanup;
1179
1180 if (rt_thread_self() == NULL) return;
1181
1182 /* get pthread data from pthread_data of thread */
1183 ptd = (_pthread_data_t *)rt_thread_self()->pthread_data;
1184 RT_ASSERT(ptd != RT_NULL);
1185
1186 if (execute)
1187 {
1188 rt_enter_critical();
1189 cleanup = ptd->cleanup;
1190 if (cleanup)
1191 ptd->cleanup = cleanup->next;
1192 rt_exit_critical();
1193
1194 if (cleanup)
1195 {
1196 cleanup->cleanup_func(cleanup->parameter);
1197
1198 rt_free(cleanup);
1199 }
1200 }
1201}
1202RTM_EXPORT(pthread_cleanup_pop);
1203
1204/**

Callers 1

searchFunction · 0.85

Calls 4

rt_thread_selfFunction · 0.85
rt_freeFunction · 0.85
rt_enter_criticalFunction · 0.50
rt_exit_criticalFunction · 0.50

Tested by

no test coverage detected