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>
This commit is contained in:
Barnabás Pőcze 2025-02-06 14:38:01 +01:00
parent 1df8091e63
commit ce333ad0d2

View file

@ -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;
}