#pragma once
|
|
#define MAX_THREAD 1
|
|
class CInspectThread;
|
|
class IThreadWorker
|
{
|
public:
|
virtual BOOL OnThreadRun(int iThread, CInspectThread *pInspectThread)= 0;
|
virtual BOOL OnThreadEnd(int iThread, CInspectThread *pInspectThread)= 0;
|
virtual BOOL OnThreadEndAll()= 0;// must be calculated by the Function (OnThreadEnd())
|
};
|
|
class CInspectThread : public CWinThread
|
{
|
DECLARE_DYNCREATE(CInspectThread)
|
protected:
|
BOOL m_bThreadRunning;
|
CRITICAL_SECTION m_csExit;
|
volatile BOOL m_bRunning;
|
BOOL m_bWorking;
|
|
int m_iThread;
|
int m_iCamera;
|
|
IThreadWorker *m_pWorker;
|
|
public:
|
CInspectThread();
|
virtual ~CInspectThread();
|
void SetWorker(IThreadWorker *pWorker){m_pWorker= pWorker;}
|
|
BOOL StartThreadLoop(int iThread); // 檬扁
|
void StartThreadWork(){m_bWorking= TRUE;}
|
|
void StopThread();
|
BOOL WaitThreadEnd(int ms= 0);
|
|
BOOL IsRunning(){return m_bRunning;}
|
|
// Overrides
|
// ClassWizard generated virtual function overrides
|
//{{AFX_VIRTUAL(CInspectionThread)
|
public:
|
virtual BOOL InitInstance();
|
virtual int ExitInstance();
|
virtual int Run();
|
//}}AFX_VIRTUAL
|
|
protected:
|
|
// Generated message map functions
|
//{{AFX_MSG(CInspectThread)
|
// NOTE - the ClassWizard will add and remove member functions here.
|
//}}AFX_MSG
|
|
DECLARE_MESSAGE_MAP()
|
};
|
|
class CThreadControl : IThreadWorker
|
{
|
int m_nThreadLoop; // 积己等 Thread Count
|
int m_nWorkingThread; // 悼累[累诀]阑 矫累茄 Thread Count
|
CInspectThread *m_pThread;
|
|
IThreadWorker *m_pThreadWorker;
|
CRITICAL_SECTION m_csWorkingEnd;
|
|
public:
|
CThreadControl(void);
|
~CThreadControl(void);
|
|
|
|
public:
|
|
// 1. Thread 磊眉狼 积己苞 家戈俊 包咯.
|
int InitThreadControl(int nThread, IThreadWorker* pThreadWorker);
|
BOOL ReleaseThreadControl();
|
|
// 2. Thread Loop 救俊辑 累诀狼 瘤矫 咯何父 牧飘费
|
int StartThreadControl();
|
void StopThreadControl();
|
|
//
|
int GetThreadLoopCount(){return m_nThreadLoop;}
|
int GetThreadWorkingCount(){return m_nWorkingThread;}
|
|
// Implementation for Interface[IthreadWorker]
|
BOOL OnThreadRun(int iThread, CInspectThread *pInspectThread);
|
BOOL OnThreadEnd(int iThread, CInspectThread *pInspectThread);
|
BOOL OnThreadEndAll();
|
|
};
|