2013-05-03 06:31:53 +00:00
|
|
|
#include "ThreadPools.h"
|
2013-05-01 12:08:01 +00:00
|
|
|
|
|
|
|
#include "../Core/Config.h"
|
2019-08-10 18:55:52 +00:00
|
|
|
#include "Common/MakeUnique.h"
|
2013-05-01 12:08:01 +00:00
|
|
|
|
2019-08-10 18:55:52 +00:00
|
|
|
std::unique_ptr<ThreadPool> GlobalThreadPool::pool;
|
|
|
|
std::once_flag GlobalThreadPool::init_flag;
|
2013-05-01 12:08:01 +00:00
|
|
|
|
2013-06-02 12:26:51 +00:00
|
|
|
void GlobalThreadPool::Loop(const std::function<void(int,int)>& loop, int lower, int upper) {
|
2019-08-10 18:55:52 +00:00
|
|
|
std::call_once(init_flag, Inititialize);
|
2013-05-01 12:08:01 +00:00
|
|
|
pool->ParallelLoop(loop, lower, upper);
|
|
|
|
}
|
|
|
|
|
|
|
|
void GlobalThreadPool::Inititialize() {
|
2019-08-10 18:55:52 +00:00
|
|
|
pool = make_unique<ThreadPool>(g_Config.iNumWorkerThreads);
|
2013-05-01 12:08:01 +00:00
|
|
|
}
|