pthread_cleanup_push_defer_np

Section: C Library Functions (3)
Updated: 2025-05-17
Index JM Home Page roff page
 

名前

pthread_cleanup_push_defer_np, pthread_cleanup_pop_restore_np - push and pop thread cancelation clean-up handlers while saving cancelability type  

ライブラリ

POSIX スレッドライブラリ (libpthread,~-lpthread)  

書式

#include <pthread.h>

void pthread_cleanup_push_defer_np(typeof(void (void *)) *routine,
                                   void *arg);
void pthread_cleanup_pop_restore_np(int execute);

glibc 向けの機能検査マクロの要件 (feature_test_macros(7) 参照):

pthread_cleanup_push_defer_np(), pthread_cleanup_pop_defer_np():

    _GNU_SOURCE
 

説明

これらの関数は pthread_cleanup_push(3) と pthread_cleanup_pop(3) と同じだが、このページで説明する点が異なる。

Like pthread_cleanup_push(3), pthread_cleanup_push_defer_np() pushes routine onto the thread's stack of cancelation clean-up handlers. In addition, it also saves the thread's current cancelability type, and sets the cancelability type to "deferred" (see pthread_setcanceltype(3)); this ensures that cancelation clean-up will occur even if the thread's cancelability type was "asynchronous" before the call.

Like pthread_cleanup_pop(3), pthread_cleanup_pop_restore_np() pops the top-most clean-up handler from the thread's stack of cancelation clean-up handlers. In addition, it restores the thread's cancelability type to its value at the time of the matching pthread_cleanup_push_defer_np().

呼び出し側では、これらの関数の呼び出しが同じ関数の中で対となり、かつ 文法的に同じネストレベル (nesting level) になることを保証しなければ ならない。 pthread_cleanup_push(3) で説明されている他の制限も 適用される。

以下の一連の呼び出し

pthread_cleanup_push_defer_np(routine, arg);
pthread_cleanup_pop_restore_np(execute);

と以下は等価である (但し、上の方がより簡潔で効率的である)。

int oldtype;

pthread_cleanup_push(routine, arg);
pthread_setcanceltype(PTHREAD_CANCEL_DEFERRED, &oldtype);
...
pthread_setcanceltype(oldtype, NULL);
pthread_cleanup_pop(execute);
 

標準規格

GNU; そのため、名前に "_np" (nonportable; 移植性がない) という接尾辞が付いている。  

歴史

glibc 2.0  

関連項目

pthread_cancel(3), pthread_cleanup_push(3), pthread_setcancelstate(3), pthread_testcancel(3), pthreads(7)


 

Index

名前
ライブラリ
書式
説明
標準規格
歴史
関連項目

This document was created by man2html, using the manual pages.