summaryrefslogtreecommitdiffstats
path: root/library/cpp/threading/local_executor/tbb_local_executor.cpp
diff options
context:
space:
mode:
authorakhropov <[email protected]>2026-02-10 14:18:29 +0300
committerakhropov <[email protected]>2026-02-10 15:12:26 +0300
commita59b4479487e7a9b533dd7da33e69601263de284 (patch)
treeee308d7a816c41f30e8d21f896e22ec6411a5a2b /library/cpp/threading/local_executor/tbb_local_executor.cpp
parenta3ebea7dd08cbf23537ffc26d56c9a0352b72913 (diff)
Return old implementation of GetWorkerThreadID. Do not persist threadId inside SetSparseFeatureBlock.,
commit_hash:0f88c1d2928f092c09638d654fca3baa6cb4f505
Diffstat (limited to 'library/cpp/threading/local_executor/tbb_local_executor.cpp')
-rw-r--r--library/cpp/threading/local_executor/tbb_local_executor.cpp18
1 files changed, 3 insertions, 15 deletions
diff --git a/library/cpp/threading/local_executor/tbb_local_executor.cpp b/library/cpp/threading/local_executor/tbb_local_executor.cpp
index cad425a1a62..661d8c3e206 100644
--- a/library/cpp/threading/local_executor/tbb_local_executor.cpp
+++ b/library/cpp/threading/local_executor/tbb_local_executor.cpp
@@ -14,21 +14,9 @@ int NPar::TTbbLocalExecutor<RespectTls>::GetThreadCount() const noexcept {
template <bool RespectTls>
int NPar::TTbbLocalExecutor<RespectTls>::GetWorkerThreadId() const noexcept {
- static thread_local int WorkerThreadId = -1;
- if (WorkerThreadId == -1) {
- // Can't rely on return value except checking that it is 'not_initialized' because of
- // "Since a thread may exit the arena at any time if it does not execute a task, the index of
- // a thread may change between any two tasks"
- // (https://oneapi-spec.uxlfoundation.org/specifications/oneapi/latest/elements/onetbb/source/task_scheduler/task_arena/this_task_arena_ns#_CPPv4N3tbb15this_task_arena20current_thread_indexEv)
- const auto tbbThreadIndex = tbb::this_task_arena::current_thread_index();
- if (tbbThreadIndex == tbb::task_arena::not_initialized) {
- // This thread does not belong to TBB worker threads
- WorkerThreadId = 0;
- } else {
- WorkerThreadId = ++RegisteredThreadCounter;
- }
- }
- return WorkerThreadId;
+ return TbbArena.execute([] {
+ return tbb::this_task_arena::current_thread_index();
+ });
}
template <bool RespectTls>