Message ID | 20250310170318.185249-1-barnabas.pocze@ideasonboard.com |
---|---|
State | Accepted |
Headers | show |
Series |
|
Related | show |
On Mon, Mar 10, 2025 at 06:03:18PM +0100, Barnabás Pőcze wrote: > `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> Nice Reviewed-by: Jacopo Mondi <jacopo.mondi@ideasonboard.com> > --- > test/threads.cpp | 8 +------- > 1 file changed, 1 insertion(+), 7 deletions(-) > > diff --git a/test/threads.cpp b/test/threads.cpp > index 8d6ee1510..c00d95a41 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; > } > -- > 2.48.1 >
Quoting Jacopo Mondi (2025-03-17 17:58:55) > > On Mon, Mar 10, 2025 at 06:03:18PM +0100, Barnabás Pőcze wrote: > > `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> > > Nice > > Reviewed-by: Jacopo Mondi <jacopo.mondi@ideasonboard.com> > > > --- > > test/threads.cpp | 8 +------- > > 1 file changed, 1 insertion(+), 7 deletions(-) > > > > diff --git a/test/threads.cpp b/test/threads.cpp > > index 8d6ee1510..c00d95a41 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); I guess this delay was uncessary ... pthread_testcancel() sounds like the right thing from the man page though! Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com> > > + pthread_testcancel(); > > > > cancelled_ = false; > > } > > -- > > 2.48.1 > >
diff --git a/test/threads.cpp b/test/threads.cpp index 8d6ee1510..c00d95a41 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; }
`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> --- test/threads.cpp | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-)