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:
parent
1df8091e63
commit
ce333ad0d2
1 changed files with 1 additions and 7 deletions
|
@ -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;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue