From 2a317173c70e98e7673480c1c61136d36f01aba4 Mon Sep 17 00:00:00 2001 From: Ed J Date: Thu, 16 Dec 2021 21:27:31 +0000 Subject: [PATCH] extract pdl_pthread_main_thread() --- Basic/Core/pdlmagic.c | 7 +++++-- Basic/Core/pdlmagic.h | 1 + 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/Basic/Core/pdlmagic.c b/Basic/Core/pdlmagic.c index d9788c564..2ca0355b2 100644 --- a/Basic/Core/pdlmagic.c +++ b/Basic/Core/pdlmagic.c @@ -395,6 +395,10 @@ pdl_error pdl_add_threading_magic(pdl *it,PDL_Indx nthdim,PDL_Indx nthreads) return PDL_err; } +char pdl_pthread_main_thread() { + return !done_pdl_main_pthreadID_init || pthread_equal( pdl_main_pthreadID, pthread_self() ); +} + // Barf/warn function for deferred barf message handling during pthreading We // can't barf/warn during pthreading, because perl-level code isn't // threadsafe. This routine does nothing if we're in the main thread (allowing @@ -407,8 +411,7 @@ int pdl_pthread_barf_or_warn(const char* pat, int iswarn, va_list *args) int* len; /* Don't do anything if we are in the main pthread */ - if( !done_pdl_main_pthreadID_init || pthread_equal( pdl_main_pthreadID, pthread_self() ) ) - return 0; + if (pdl_pthread_main_thread()) return 0; if(iswarn) { diff --git a/Basic/Core/pdlmagic.h b/Basic/Core/pdlmagic.h index 08fea6d7a..50518a1e9 100644 --- a/Basic/Core/pdlmagic.h +++ b/Basic/Core/pdlmagic.h @@ -121,6 +121,7 @@ pdl_trans *pdl_find_mutatedtrans(pdl *it); /* Threading magic */ /* Deferred barfing and warning when pthreading */ +char pdl_pthread_main_thread(); int pdl_pthread_barf_or_warn(const char* pat, int iswarn, va_list *args); pdl_error pdl_add_threading_magic(pdl *,PDL_Indx nthdim, PDL_Indx nthreads);