workerthread.h

来自「Linux 下的线程池的源代码。很好用!」· C头文件 代码 · 共 48 行

H
48
字号
#ifndef _WORKERTHREAD_H_#define _WORKERTHREAD_H_#include "Thread.h"#include "ThreadPool.h"#include "Job.h"#include "../sync/sync.h"/************************************************************** *For class CThread is an abstract class,it can't be instantiated *class CWorkerThread is the actual thread that run the job,but * **************************************************************///class CThreadPool;class CWorkerThread:public CThread{private:    CThreadPool*  m_ThreadPool;        //the job that associate with the workthread    CJob*	 m_Job;    void*	 m_JobData;	        CThreadMutex m_VarMutex;    bool 	 m_IsEnd;protected:public:    CCondition   m_JobCond;    CThreadMutex m_WorkMutex;      CWorkerThread();    virtual ~CWorkerThread();        void Run();         void    SetJob(CJob* job,void* jobdata);     CJob*   GetJob(void){return m_Job;}    void    SetThreadPool(CThreadPool* thrpool);    CThreadPool* GetThreadPool(void){return m_ThreadPool;}    bool    IsWorking(void){return m_Job != NULL;}     void    Wakeup(CJob* job,void* jobdata);};#endif

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?