⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 workerthread.h

📁 Linux 下的线程池的源代码。很好用!
💻 H
字号:
#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 + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -