You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

88 lines
2.3 KiB

#ifndef __BASICDUALTHREAD_H_INCL__
#define __BASICDUALTHREAD_H_INCL__
#include "basicThread.h"
/**
* TODO: Add class description
*
* @author Gagua
*/
class basicDualThread {
private:
#if defined( __linux__ ) || defined(WIN_PTHREAD)
pthread_t m_sThreadAHandler;
static void *m_fThreadAEntryPoint(void *);
pthread_t m_sThreadBHandler;
static void *m_fThreadBEntryPoint(void *);
#else
HANDLE m_hThreadAHandle;
HANDLE m_hThreadBHandle;
DWORD m_dwThreadAID;
DWORD m_dwThreadBID;
static DWORD WINAPI m_fThreadAEntryPoint( LPVOID lpParameter );
static DWORD WINAPI m_fThreadBEntryPoint( LPVOID lpParameter );
#endif
protected:
thredStatus m_bThreadAStatus;
virtual void m_fThreadAProc( void );
thredStatus m_bThreadBStatus;
virtual void m_fThreadBProc( void );
basicLogCollection *m_pLog;
public:
// Constructor
basicDualThread();
// Destructor
~basicDualThread();
virtual bool init( void );
thredStatus getAStatus( void ){ return m_bThreadAStatus; };
thredStatus getBStatus(void){ return m_bThreadBStatus; };
void waitThreadAEnd( bool Force = true );
void waitThreadBEnd( bool Force = true );
};
// Constructor implementation
inline basicDualThread::basicDualThread(){
m_pLog = basicLogCollection::getInstance();
m_bThreadAStatus = TH_PRE_INIT;
m_bThreadBStatus = TH_PRE_INIT;
};
// Destructor implementation
inline basicDualThread::~basicDualThread(){
if( m_bThreadAStatus > TH_ARMED ) {
waitThreadAEnd();
// Threads are detached inside Wait
//pthread_detach( m_sThreadAHandler );
};
if( m_bThreadBStatus > TH_ARMED ) {
waitThreadBEnd();
//pthread_detach( m_sThreadBHandler );
};
};
// TODO: Uncomment the copy constructor when you need it.
//inline basicThread::basicThread(const basicThread& src)
//{
// // TODO: copy
//}
// TODO: Uncomment the assignment operator when you need it.
//inline basicThread& basicThread::operator=(const basicThread& rhs)
//{
// if (this == &rhs) {
// return *this;
// }
//
// // TODO: assignment
//
// return *this;
//}
#endif // __BASICTHREAD_H_INCL__