table of contents
- bookworm-backports 4.26.0-1~bpo12+1
pthread_cleanup_push_defer_np(3) | Library Functions Manual | pthread_cleanup_push_defer_np(3) |
НАИМЕНОВАНИЕ¶
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(void (*routine)(void *), void *arg); void pthread_cleanup_pop_restore_np(int execute);
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().
Вызывающий должен гарантировать, что вызовы этих функций будут попарными внутри одной функции, и на одном лексическом уровне вложенности. Остальные ограничения описаны в 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).
СМОТРИТЕ ТАКЖЕ¶
pthread_cancel(3), pthread_cleanup_push(3), pthread_setcancelstate(3), pthread_testcancel(3), pthreads(7)
ПЕРЕВОД¶
Русский перевод этой страницы руководства разработал(и) Alexey, Azamat Hackimov <azamat.hackimov@gmail.com>, kogamatranslator49 <r.podarov@yandex.ru>, Darima Kogan <silverdk99@gmail.com>, Max Is <ismax799@gmail.com>, Yuri Kozlov <yuray@komyakino.ru>, Иван Павлов <pavia00@gmail.com> и Kirill Rekhov <krekhov.dev@gmail.com>
Этот перевод является свободной программной документацией; он распространяется на условиях общедоступной лицензии GNU (GNU General Public License - GPL, https://www.gnu.org/licenses/gpl-3.0.html версии 3 или более поздней) в отношении авторского права, но БЕЗ КАКИХ-ЛИБО ГАРАНТИЙ.
Если вы обнаружите какие-либо ошибки в переводе этой страницы руководства, пожалуйста, сообщите об этом разработчику(ам) по его(их) адресу(ам) электронной почты или по адресу списка рассылки русских переводчиков.
30 октября 2022 г. | Справочные страницы Linux 6.03 |