summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBarnabás Pőcze <barnabas.pocze@ideasonboard.com>2025-02-06 14:38:01 +0100
committerBarnabás Pőcze <barnabas.pocze@ideasonboard.com>2025-03-21 17:35:41 +0100
commitce333ad0d288ff1d63d2dc50210e37b0c7e93614 (patch)
treef719fdd4890482dc0f8415a66e3a226cd353d347
parent1df8091e631b72df8ecda105dae7934b54b1287c (diff)
test: threads: Use `pthread_testcancel()`
`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 <barnabas.pocze@ideasonboard.com> Reviewed-by: Jacopo Mondi <jacopo.mondi@ideasonboard.com> Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
-rw-r--r--test/threads.cpp8
1 files changed, 1 insertions, 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;
}