Пример #1
0
//create num idle thread and put them to idlelist
void CThreadPool::CreateIdleThread(int num)
{
    for(int i=0;i<num;i++)
    {
	CWorkerThread* thr = new CWorkerThread();
	thr->SetThreadPool(this);
	AppendToIdleList(thr);
	m_VarMutex.Lock();
	m_AvailNum++;
	m_VarMutex.Unlock();
	//printf("===============Create A New Thread================\n");
	thr->Start();		//begin the thread,the thread wait for job
    }
}
Пример #2
0
	void SmtThreadPool::CreateThread(int nNum)
	{
		for(int i=0;i<nNum;i++)
		{ 
			SmtWorkThread* pThread = new SmtWorkThread(); 
			m_vThreads.push_back(pThread);

			AppendToIdleList(pThread);

			pThread->SetThreadPool(this); 

			pThread->Start();       //begin the thread,the thread wait for job 
			pThread->Resume();
			//pThread->Suspend();
		}
	}
Пример #3
0
CThreadPool::CThreadPool()
{
    m_MaxNum = 50;
    m_AvailLow = 5;
    m_InitNum=m_AvailNum = 10 ;
    m_AvailHigh = 20;

    m_BusyList.clear();
    m_IdleList.clear();
    for(int i=0;i<m_AvailNum;i++)
    {
	//printf("create a thread\n");
	CWorkerThread* thr = new CWorkerThread();
	thr->SetThreadPool(this);
	AppendToIdleList(thr);
	thr->Start();
    }
}
Пример #4
0
CThreadPool::CThreadPool(int initnum)
{
    assert(initnum>0 && initnum<=30);
    m_MaxNum   = 30;
    m_AvailLow = initnum-10>0?initnum-10:3;
    m_InitNum=m_AvailNum = initnum ;
    m_AvailHigh = initnum+10;

    m_BusyList.clear();
    m_IdleList.clear();
    for(int i=0;i<m_AvailNum;i++)
    {
    //printf("create a thread\n");
	CWorkerThread* thr = new CWorkerThread();
	AppendToIdleList(thr);
	thr->SetThreadPool(this);
	thr->Start();		//begin the thread,the thread wait for job
    }
}