library/src/threads/BP-LinuxThreads.cc
// DESIGNED TO BE CALLED FROM THREAD MANAGER: This function can be used in a manager/dispatcher
// to safely check the status of a thread.  The threads are responsible for setting their own statuses
// upon exit/termination.
DESIGNED TO BE CALLED FROM THREAD MANAGER: This function can be used in a manager/dispatcher
to safely check the status of a thread.  The threads are responsible for setting their own statuses
upon exit/termination.
DESIGNED TO BE CALLED FROM THREAD MANAGER : This function can be used in a manager / dispatcher to safely check the status of a thread . The threads are responsible for setting their own statuses upon exit / termination .
BP_THREAD_STATUS CheckThreadStatusCode(P_THREAD_LIST thread_elem)
{
	if(!thread_elem)
		return BP_THREAD_STATUS_UNDEFINED;
	while(LockMutex((pthread_mutex_t *) &thread_elem->thread_lock) != ERR_SUCCESS){};
	BP_THREAD_STATUS status = thread_elem->threadState;
	while(UnlockMutex((pthread_mutex_t *) &thread_elem->thread_lock) != ERR_SUCCESS){};
	return status;
}
BP_THREAD_STATUS CheckThreadStatusCode ( P_THREAD_LIST thread_elem ) { if ( ! thread_elem ) return BP_THREAD_STATUS_UNDEFINED ; while ( LockMutex ( ( pthread_mutex_t * ) & thread_elem -> thread_lock ) != ERR_SUCCESS ) { } ; BP_THREAD_STATUS status = thread_elem -> threadState ; while ( UnlockMutex ( ( pthread_mutex_t * ) & thread_elem -> thread_lock ) != ERR_SUCCESS ) { } ; return status ; }
DESIGNED TO BE CALLED FROM THREAD MANAGER: This function can be used in a manager/dispatcher
to safely check the status of a thread.
DESIGNED TO BE CALLED FROM THREAD MANAGER : This function can be used in a manager / dispatcher to safely check the status of a thread .
// ensure that the thread element is non-null // try to lock the mutex // set status from thread state // unlock the mutex // return the retrieved status code