9 #ifndef PHYSICSTOOLS_TENSORFLOW_TBBTHREADPOOL_H
10 #define PHYSICSTOOLS_TENSORFLOW_TBBTHREADPOOL_H
14 #include "tensorflow/core/lib/core/threadpool.h"
16 #include "tbb/task_scheduler_init.h"
17 #include "tbb/task_arena.h"
18 #include "tbb/task_group.h"
39 tbb::task_arena taskArena;
40 tbb::task_group taskGroup;
43 auto doneWithTaskGroup = [&taskArena, &taskGroup](
void*) {
44 taskArena.execute([&taskGroup]() { taskGroup.wait(); });
46 std::unique_ptr<tbb::task_group, decltype(doneWithTaskGroup)> taskGuard(&taskGroup, doneWithTaskGroup);
49 taskArena.execute([&taskGroup, &
fn] { taskGroup.run(
fn); });
62 static std::atomic<int> idCounter{0};
63 thread_local
const int id = idCounter++;
76 #endif // PHYSICSTOOLS_TENSORFLOW_TBBTHREADPOOL_H