From ce333ad0d288ff1d63d2dc50210e37b0c7e93614 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Barnab=C3=A1s=20P=C5=91cze?= Date: Thu, 6 Feb 2025 14:38:01 +0100 Subject: test: threads: Use `pthread_testcancel()` MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit `pthread_testcancel()` is a guaranteed cancellation point, specifically for testing if cancellation has been requested, so use it. Signed-off-by: Barnabás Pőcze Reviewed-by: Jacopo Mondi Reviewed-by: Kieran Bingham --- test/threads.cpp | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/test/threads.cpp b/test/threads.cpp index 8d6ee151..c00d95a4 100644 --- a/test/threads.cpp +++ b/test/threads.cpp @@ -52,14 +52,8 @@ protected: { cancelled_ = true; - /* - * Cancel the thread and call a guaranteed cancellation point - * (nanosleep). - */ pthread_cancel(pthread_self()); - - struct timespec req{ 0, 100*000*000 }; - nanosleep(&req, nullptr); + pthread_testcancel(); cancelled_ = false; } -- cgit v1.2.1