ThreadPool::ThreadPool(int nThreads, int bulkDequeue):
     _max{nThreads},
     _bulkDequeue{bulkDequeue},
     _token(_queue)
 {
     for (int i = 0; i < nThreads; ++i)
     {
         TaskWorker* worker = new TaskWorker(&_queue, _bulkDequeue);
         worker->start();
         _workers.push_back(worker);
     }
 }
Exemple #2
0
gep::TaskQueue::TaskQueue()
    : m_localWorker(this),
    m_currentTaskGroup(nullptr),
    m_isRunning(true)
{
    TaskWorker* localWorker = &m_localWorker;
    m_worker.append(localWorker);
    for(size_t i=1; i < 8/*std::thread::hardware_concurrency()*/; i++)
    {
        TaskWorker* newWorker = new TaskWorker(this);
        newWorker->start();
        m_worker.append(newWorker);
    }
}