7 #ifndef __FWDATATOOLS_THREAD_REGIONTHREADER_HPP__ 8 #define __FWDATATOOLS_THREAD_REGIONTHREADER_HPP__ 29 : m_nbThread( (std::thread::hardware_concurrency() > 1) ? std::thread::hardware_concurrency() : 1 )
34 : m_nbThread( std::min( capped ? std::thread::hardware_concurrency() : std::numeric_limits<size_t>::max(),
35 (nbThread > 1) ? nbThread : 1) )
39 template<
typename T>
void operator()(T func,
const size_t dataSize)
41 std::vector< std::thread* > threads;
43 const size_t step = (dataSize / m_nbThread) + 1;
44 size_t regionBegin = 0;
49 for (; regionBegin < dataSize; regionBegin += step, ++threadId)
51 threads.push_back(
new std::thread(func, regionBegin, std::min( dataSize, regionBegin + step),
55 for( std::thread *thread: threads)
68 size_t numberOfThread()
75 const size_t m_nbThread;
83 #endif //__FWDATATOOLS_THREAD_REGIONTHREADER_HPP__