Exemplo n.º 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
    }
}
Exemplo n.º 2
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();
    }
}
Exemplo n.º 3
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
    }
}