pthread_cleanup.h¶
Cleanup primitives for pthread threads.
Note
Do not include this header file directly, but pthread.h.
-
pthread_cleanup_push
( ROUTINE, ARG)¶ Open a cleanup frame.
1 2 3 4 5 6 7 8 9
do { \ __extension__ __pthread_cleanup_datum_t ____datum__ = { \ .__routine = (ROUTINE), \ .__arg = (ARG), \ }; \ __extension__ int ____execute__ = 1; \ __pthread_cleanup_push(&____datum__); \ do { \ do { } while (0)
This function must be paired with
pthread_cleanup.h::pthread_cleanup_pop
.The cleanup function is called if the current thread exists inside the frame by means of
pthread_threading.h::pthread_exit()
, or if the thread was cancelled.You must not
return
,continue
, orbreak
out of the cleanup frame.The frame opens a scope. Variables declared inside this scope won’t be visible outside.
Parameters
ROUTINE: Function to call on cleanup. ARG: Argument to supply to the cleanup handler.
-
pthread_cleanup_pop
( EXECUTE)¶ Closes a cleaup frame.
1 2 3 4
____execute__ = (EXECUTE); \ } while (0); \ __pthread_cleanup_pop(&____datum__, ____execute__); \ } while (0)
Must be paired with
pthread_cleanup.h::pthread_cleanup_push
.Parameters
EXECUTE: Iff != 0
call cleanup handler.
-
struct __pthread_cleanup_datum
__pthread_cleanup_datum_t
¶ Internal structure for
pthread_cleanup.h::pthread_cleanup_push
-
void
__pthread_cleanup_push
(pthread_cleanup.h::__pthread_cleanup_datum_t
* datum)¶ Internal function to be called by
pthread_cleanup.h::pthread_cleanup_push
The previous top of the stack gets stored in
datum->next
.Parameters
datum: Allocated in the stack, datum tells how to cleanup.
-
void
__pthread_cleanup_pop
(pthread_cleanup.h::__pthread_cleanup_datum_t
* datum, int execute)¶ Internal function to be called by
pthread_cleanup.h::pthread_cleanup_push
This function leaves the cleanup frame that was opened with
pthread_cleanup.h::__pthread_cleanup_push()
.Parameters
datum: Parameter that was supplied to pthread_cleanup.h::__pthread_cleanup_push()
.execute: Iff != 0
call cleanup handler.