#ifndef __MwlMxpThreadBase_H__
#define __MwlMxpThreadBase_H__

#include "mwlmpx_internal_common.h"

class CMyuThreadManager;

//	クラス宣言
class _MWLMXP_LIB_EXP CMwlMxpThreadBase : public mxp::CThreadBase
{
private:
	typedef struct {
		int userParam;
		CMwlMxpThreadBase* pThis;
	} _THREAD_PARAM;
	//} MWLMXP_THREAD_PARAM;
	_THREAD_PARAM m_paramWork;

	CMyuThreadManager* m_pThreadMgr;

	//unsigned long PrivateThreadFunc(void *lpParam);
	static unsigned long PrivateThreadFunc(_THREAD_PARAM* pParam);

public:
	//	コンストラクタ・デストラクタ
	CMwlMxpThreadBase();
	virtual ~CMwlMxpThreadBase();

	virtual bool StartThread(int anyParam);
	virtual bool IsThreadEnded();
	virtual bool ThreadWaitEnd(int nTimeoutMs=MXP_THREAD_TIMEOUT_MS_INIFINITE );
	virtual bool ThreadForceEnd();
};

namespace mwlmxp
{
	typedef ::CMwlMxpThreadBase CThreadBase;
}

/////////////////////////////////////////////////

//	クラス宣言
template <typename T> class TMwlMxpThreadBase : public T
{
private:
	CMyuThreadManager m_threadMgr;

	unsigned long PrivateThreadFunc(void *lpParam);
protected:
	//virtual bool ThreadFunc()=0;

public:
	//	コンストラクタ・デストラクタ
	TMwlMxpThreadBase(){}
	virtual ~TMwlMxpThreadBase(){}

	bool StartThread();
	bool IsThreadAlive();
	bool ThreadWaitEnd( DWORD dwTimeoutMs=INFINITE );
	bool ThreadForceEnd();
};

#endif//__MwlMxpThreadBase_H__