www.pudn.com > xianchengchi.rar > WorkThreadPool.cpp
// WorkThreadPool.cpp: implementation of the CWorkThreadPool class.
//
//////////////////////////////////////////////////////////////////////
#include "stdafx.h"
#include "Thread.h"
#include "WorkThreadPool.h"
#ifdef _DEBUG
#undef THIS_FILE
static char THIS_FILE[]=__FILE__;
#define new DEBUG_NEW
#endif
//////////////////////////////////////////////////////////////////////
// Construction/Destruction
//////////////////////////////////////////////////////////////////////
CWorkThreadPool::CWorkThreadPool() :
m_exit(false,true),m_signal(false,true)
{
pf = NULL;
m_threadNum = 3;
}
CWorkThreadPool::~CWorkThreadPool()
{
}
void CWorkThreadPool::Run()
{
for(int i=0;iWork();
return 0;
}
void CWorkThreadPool::Stop()
{
m_signal.ResetEvent();
m_exit.SetEvent();
while (m_threadNum)
{
Sleep(10);
}
}
void CWorkThreadPool::RemoveWorkItem(LPVOID _pItem)
{
LPVOID pItem = NULL;
m_lock.Lock();
for(int i=0;i 0);
m_threadNum = num;
}