#include "pls/internal/scheduling/tbb_task.h" namespace pls { namespace internal { namespace scheduling { tbb_sub_task::tbb_sub_task(tbb_sub_task *parent, class tbb_task *tbb_task): ref_count_{0}, parent_{parent}, tbb_task_{tbb_task} { parent->ref_count_++; } tbb_sub_task::~tbb_sub_task() { wait_for_all(); } void tbb_sub_task::execute() { execute_internal(); wait_for_all(); } tbb_sub_task* tbb_sub_task::get_local_task() { // TODO: get a task from the bottom of our sub-task queue } void tbb_sub_task::wait_for_all() { while (ref_count_ > 0) { tbb_sub_task* local_task = get_local_task(); if (local_task != nullptr) { local_task->execute(); continue; } else { // Try to steal work. // External steal will be executed explicitly if (tbb_task_->steal_work()) { // TODO: Internal Success, execute stolen task } } } } } } }