diff options
author | arcadia-devtools <arcadia-devtools@yandex-team.ru> | 2022-02-10 16:48:02 +0300 |
---|---|---|
committer | Daniil Cherednik <dcherednik@yandex-team.ru> | 2022-02-10 16:48:02 +0300 |
commit | a61e8c559b6b690a019253067224d595e3d642f1 (patch) | |
tree | b222e5ac2e2e98872661c51ccceee5da0d291e13 /library/cpp/threading/local_executor/tbb_local_executor.cpp | |
parent | 659131349be7796c633c453b4d8b4fa20b8c6ee9 (diff) | |
download | ydb-a61e8c559b6b690a019253067224d595e3d642f1.tar.gz |
Restoring authorship annotation for <arcadia-devtools@yandex-team.ru>. Commit 2 of 2.
Diffstat (limited to 'library/cpp/threading/local_executor/tbb_local_executor.cpp')
-rw-r--r-- | library/cpp/threading/local_executor/tbb_local_executor.cpp | 106 |
1 files changed, 53 insertions, 53 deletions
diff --git a/library/cpp/threading/local_executor/tbb_local_executor.cpp b/library/cpp/threading/local_executor/tbb_local_executor.cpp index 9903ef33de..65d6659443 100644 --- a/library/cpp/threading/local_executor/tbb_local_executor.cpp +++ b/library/cpp/threading/local_executor/tbb_local_executor.cpp @@ -1,53 +1,53 @@ -#include "tbb_local_executor.h" - -template <bool RespectTls> -void NPar::TTbbLocalExecutor<RespectTls>::SubmitAsyncTasks(TLocallyExecutableFunction exec, int firstId, int lastId) { - for (int i = firstId; i < lastId; ++i) { - Group.run([=] { exec(i); }); - } -} - -template <bool RespectTls> -int NPar::TTbbLocalExecutor<RespectTls>::GetThreadCount() const noexcept { - return NumberOfTbbThreads - 1; -} - -template <bool RespectTls> -int NPar::TTbbLocalExecutor<RespectTls>::GetWorkerThreadId() const noexcept { - return TbbArena.execute([] { - return tbb::this_task_arena::current_thread_index(); - }); -} - -template <bool RespectTls> -void NPar::TTbbLocalExecutor<RespectTls>::Exec(TIntrusivePtr<ILocallyExecutable> 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 <bool RespectTls> -void NPar::TTbbLocalExecutor<RespectTls>::ExecRange(TIntrusivePtr<ILocallyExecutable> 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<true>; -template class NPar::TTbbLocalExecutor<false>; +#include "tbb_local_executor.h" + +template <bool RespectTls> +void NPar::TTbbLocalExecutor<RespectTls>::SubmitAsyncTasks(TLocallyExecutableFunction exec, int firstId, int lastId) { + for (int i = firstId; i < lastId; ++i) { + Group.run([=] { exec(i); }); + } +} + +template <bool RespectTls> +int NPar::TTbbLocalExecutor<RespectTls>::GetThreadCount() const noexcept { + return NumberOfTbbThreads - 1; +} + +template <bool RespectTls> +int NPar::TTbbLocalExecutor<RespectTls>::GetWorkerThreadId() const noexcept { + return TbbArena.execute([] { + return tbb::this_task_arena::current_thread_index(); + }); +} + +template <bool RespectTls> +void NPar::TTbbLocalExecutor<RespectTls>::Exec(TIntrusivePtr<ILocallyExecutable> 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 <bool RespectTls> +void NPar::TTbbLocalExecutor<RespectTls>::ExecRange(TIntrusivePtr<ILocallyExecutable> 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<true>; +template class NPar::TTbbLocalExecutor<false>; |