#include "tbb_local_executor.h" template void NPar::TTbbLocalExecutor::SubmitAsyncTasks(TLocallyExecutableFunction exec, int firstId, int lastId) { for (int i = firstId; i < lastId; ++i) { Group.run([=] { exec(i); }); } } template int NPar::TTbbLocalExecutor::GetThreadCount() const noexcept { return NumberOfTbbThreads - 1; } template int NPar::TTbbLocalExecutor::GetWorkerThreadId() const noexcept { return TbbArena.execute([] { return tbb::this_task_arena::current_thread_index(); }); } template void NPar::TTbbLocalExecutor::Exec(TIntrusivePtr exec, int id, int flags) { if (flags & WAIT_COMPLETE) { exec->LocalExec(id); } else { TbbArena.execute([=] { SubmitAsyncTasks([=] (int id) { exec->LocalExec(id); }, id, id + 1); }); } } template void NPar::TTbbLocalExecutor::ExecRange(TIntrusivePtr exec, int firstId, int lastId, int flags) { if (flags & WAIT_COMPLETE) { TbbArena.execute([=] { if (RespectTls) { tbb::this_task_arena::isolate([=]{ tbb::parallel_for(firstId, lastId, [=] (int id) { exec->LocalExec(id); }); }); } else { tbb::parallel_for(firstId, lastId, [=] (int id) { exec->LocalExec(id); }); } }); } else { TbbArena.execute([=] { SubmitAsyncTasks([=] (int id) { exec->LocalExec(id); }, firstId, lastId); }); } } template class NPar::TTbbLocalExecutor; template class NPar::TTbbLocalExecutor;