#pragma once

#include <thread>
#include "condition_signal.h"

typedef enum
{
	ZCThread_Status_Init,
	ZCThread_Status_Running,
	ZCThread_Status_Pause,
	ZCThread_Status_Stopped,
}ZCThreadStatus;

class ZCWorkThread
{
public:
	ZCWorkThread(const char *threadName);
	virtual ~ZCWorkThread();

	void StartThread();
	void PauseThread();
	void StopThread();

	virtual void DoRunning() = 0;

private:
	static void *cbThreadProcess(void *param)
	{
		ZCWorkThread *threadEntry = (ZCWorkThread *)param;
		return threadEntry->threadProcess();
	}
	void *threadProcess();

private:
	ZCThreadStatus	m_nStatus;
	ZCSignal		m_pauseSignal; //线程暂停前去触发该信号
	ZCSignal        m_workSignal;  //该信号被触发后，线程才去工作

private:
	std::string    m_strName;
	std::thread    *m_threadEntry;
};