Skip to content

Commit

Permalink
extract pdl_pthread_main_thread()
Browse files Browse the repository at this point in the history
  • Loading branch information
mohawk2 committed Dec 16, 2021
1 parent 878f9a0 commit 2a31717
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
7 changes: 5 additions & 2 deletions Basic/Core/pdlmagic.c
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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)
{
Expand Down
1 change: 1 addition & 0 deletions Basic/Core/pdlmagic.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit 2a31717

Please sign in to comment.