2013-05-01 12:08:01 +00:00
|
|
|
#include "ThreadPool.h"
|
|
|
|
|
|
|
|
#include "../Core/Config.h"
|
|
|
|
|
2013-05-02 07:06:09 +00:00
|
|
|
shared_ptr<ThreadPool> GlobalThreadPool::pool;
|
2013-05-01 12:08:01 +00:00
|
|
|
bool GlobalThreadPool::initialized = false;
|
|
|
|
|
2013-05-02 07:06:09 +00:00
|
|
|
void GlobalThreadPool::Loop(const function<void(int,int)>& loop, int lower, int upper) {
|
2013-05-01 12:08:01 +00:00
|
|
|
Inititialize();
|
|
|
|
pool->ParallelLoop(loop, lower, upper);
|
|
|
|
}
|
|
|
|
|
|
|
|
void GlobalThreadPool::Inititialize() {
|
|
|
|
if(!initialized) {
|
|
|
|
pool = std::make_shared<ThreadPool>(g_Config.iNumWorkerThreads);
|
|
|
|
initialized = true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|