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:
@@ -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;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user