42inline void forEach(RangeT range, 
const FuncT &func)
 
   44    if (range.empty()) 
return;
 
   46    tbb::parallel_for(range, func);
 
   48    if (
const size_t threadCount = std::thread::hardware_concurrency()>>1) {
 
   49        std::vector<RangeT> rangePool{ range };
 
   50        while(rangePool.size() < threadCount) {
 
   51            const size_t oldSize = rangePool.size();
 
   52            for (
size_t i = 0; i < oldSize && rangePool.size() < threadCount; ++i) {
 
   53                auto &r = rangePool[i];
 
   54                if (r.is_divisible()) rangePool.push_back(RangeT(r, 
Split()));
 
   56            if (rangePool.size() == oldSize) 
break;
 
   58        std::vector<std::thread> threadPool;
 
   59        for (
auto &r : rangePool) threadPool.emplace_back(func, r);
 
   60        for (
auto &t : threadPool) t.join();