|
|
|
@ -73,10 +73,8 @@ void basicDualThread::m_fThreadBProc( void ){ |
|
|
|
#endif
|
|
|
|
basicDualThread *mThis; |
|
|
|
mThis = ( basicDualThread * ) ptr; |
|
|
|
if( mThis->m_bThreadAStatus == TH_ARMED ) { |
|
|
|
mThis->m_fThreadAProc(); |
|
|
|
mThis->m_bThreadAStatus = TH_EXIT; |
|
|
|
}; |
|
|
|
if( mThis->m_bThreadAStatus == TH_ARMED ) mThis->m_fThreadAProc(); |
|
|
|
mThis->m_bThreadAStatus = TH_EXIT; |
|
|
|
#ifdef DEBUG_EXTRA
|
|
|
|
mThis->SLOG("ThreadAEntryPoint Exit."); |
|
|
|
#endif
|
|
|
|
@ -95,10 +93,8 @@ void basicDualThread::m_fThreadBProc( void ){ |
|
|
|
#endif
|
|
|
|
basicDualThread *mThis; |
|
|
|
mThis = ( basicDualThread * ) ptr; |
|
|
|
if( mThis->m_bThreadBStatus == TH_ARMED ) { |
|
|
|
mThis->m_fThreadBProc(); |
|
|
|
mThis->m_bThreadBStatus = TH_EXIT; |
|
|
|
}; |
|
|
|
if( mThis->m_bThreadBStatus == TH_ARMED ) mThis->m_fThreadBProc(); |
|
|
|
mThis->m_bThreadBStatus = TH_EXIT; |
|
|
|
#ifdef DEBUG_EXTRA
|
|
|
|
mThis->SLOG("ThreadBEntryPoint Exit."); |
|
|
|
#endif
|
|
|
|
@ -111,85 +107,41 @@ void basicDualThread::m_fThreadBProc( void ){ |
|
|
|
}; |
|
|
|
|
|
|
|
void basicDualThread::waitThreadAEnd( bool Force ){ |
|
|
|
if( m_bThreadAStatus > TH_WORKING || m_bThreadAStatus < TH_ARMED ) { |
|
|
|
#ifdef DEBUG_EXTRA
|
|
|
|
LOG("Thread A already Dead!"); |
|
|
|
#endif
|
|
|
|
return; |
|
|
|
}; |
|
|
|
if( Force ){ |
|
|
|
#ifdef DEBUG_EXTRA
|
|
|
|
LOG("Thread A Requested Exit."); |
|
|
|
#endif
|
|
|
|
m_bThreadAStatus = TH_ENDED; |
|
|
|
} else { |
|
|
|
#ifdef DEBUG_EXTRA
|
|
|
|
LOG("Thread A Wait Exit."); |
|
|
|
#endif
|
|
|
|
}; |
|
|
|
while( m_bThreadAStatus != TH_EXIT ) SLEEP(DEFAULT_THREAD_SLEEP_TIME); |
|
|
|
if( m_bThreadAStatus > TH_WORKING || m_bThreadAStatus < TH_ARMED ) return; |
|
|
|
if( Force && m_bThreadAStatus < TH_EXIT) m_bThreadAStatus = TH_ENDED; |
|
|
|
|
|
|
|
while( m_bThreadAStatus < TH_EXIT ) SLEEP( DEFAULT_THREAD_SLEEP_TIME ); |
|
|
|
|
|
|
|
#if defined( __linux__ ) || defined(WIN_PTHREAD)
|
|
|
|
pthread_join(m_sThreadAHandler, NULL); |
|
|
|
#else
|
|
|
|
WaitForSingleObject(m_hThreadAHandle, 2000); |
|
|
|
CloseHandle(m_hThreadAHandle); |
|
|
|
#endif
|
|
|
|
#ifdef DEBUG_EXTRA
|
|
|
|
LOG("Thread A Ended."); |
|
|
|
#endif
|
|
|
|
}; |
|
|
|
|
|
|
|
void basicDualThread::waitThreadBEnd( bool Force ){ |
|
|
|
if( m_bThreadBStatus > TH_WORKING || m_bThreadBStatus < TH_ARMED ){ |
|
|
|
#ifdef DEBUG_EXTRA
|
|
|
|
LOG("Thread B already Dead!"); |
|
|
|
#endif
|
|
|
|
return; |
|
|
|
}; |
|
|
|
if( Force ){ |
|
|
|
#ifdef DEBUG_EXTRA
|
|
|
|
LOG("Thread B Requested Exit."); |
|
|
|
#endif
|
|
|
|
m_bThreadBStatus = TH_ENDED; |
|
|
|
} else { |
|
|
|
#ifdef DEBUG_EXTRA
|
|
|
|
LOG("Thread B Wait Exit."); |
|
|
|
#endif
|
|
|
|
}; |
|
|
|
while( m_bThreadBStatus != TH_EXIT ) SLEEP(DEFAULT_THREAD_SLEEP_TIME); |
|
|
|
if( m_bThreadBStatus > TH_WORKING || m_bThreadBStatus < TH_ARMED ) return; |
|
|
|
if( Force && m_bThreadBStatus < TH_EXIT ) m_bThreadBStatus = TH_ENDED; |
|
|
|
|
|
|
|
while( m_bThreadBStatus < TH_EXIT ) SLEEP(DEFAULT_THREAD_SLEEP_TIME); |
|
|
|
|
|
|
|
#if defined( __linux__ ) || defined(WIN_PTHREAD)
|
|
|
|
pthread_join(m_sThreadBHandler, NULL); |
|
|
|
#else
|
|
|
|
WaitForSingleObject(m_hThreadBHandle, 2000); |
|
|
|
CloseHandle(m_hThreadBHandle); |
|
|
|
#endif
|
|
|
|
#ifdef DEBUG_EXTRA
|
|
|
|
LOG("Thread B Ended."); |
|
|
|
#endif
|
|
|
|
}; |
|
|
|
|
|
|
|
bool basicDualThread::uninit( void ){ |
|
|
|
if( m_bThreadAStatus == TH_PRE_INIT && m_bThreadBStatus == TH_PRE_INIT ) return true; |
|
|
|
if( m_bThreadAStatus == TH_ARMED || m_bThreadBStatus == TH_ARMED ) while( m_bThreadAStatus < TH_WORKING || m_bThreadBStatus < TH_WORKING ) SLEEP(1); |
|
|
|
if( m_bThreadBStatus == TH_WORKING ) m_bThreadBStatus = TH_ENDED; |
|
|
|
if( m_bThreadAStatus == TH_WORKING ) m_bThreadAStatus = TH_ENDED; |
|
|
|
|
|
|
|
while( m_bThreadAStatus < TH_EXIT || m_bThreadBStatus < TH_EXIT ) SLEEP(1); |
|
|
|
|
|
|
|
#if defined( __linux__ ) || defined(WIN_PTHREAD)
|
|
|
|
pthread_join(m_sThreadAHandler, NULL); |
|
|
|
pthread_join(m_sThreadBHandler, NULL); |
|
|
|
#else
|
|
|
|
WaitForSingleObject(m_hThreadAHandle, 2000); |
|
|
|
WaitForSingleObject(m_hThreadBHandle, 2000); |
|
|
|
CloseHandle(m_hThreadAHandle); |
|
|
|
CloseHandle(m_hThreadBHandle); |
|
|
|
#endif
|
|
|
|
waitThreadAEnd( true ); |
|
|
|
waitThreadBEnd( true ); |
|
|
|
#ifdef DEBUG_EXTRA
|
|
|
|
LOG("UNINIT done!"); |
|
|
|
#endif
|
|
|
|
m_bThreadAStatus = TH_PRE_INIT; |
|
|
|
m_bThreadBStatus = TH_PRE_INIT; |
|
|
|
m_bThreadAStatus = m_bThreadBStatus = TH_PRE_INIT; |
|
|
|
return true; |
|
|
|
}; |
|
|
|
|
|
|
|
|