I have an application where I need to be able to retreive the value of a std::future from inside a task. However, as blocking inside a task is a bad idea, I've run into a bit of a challenge.
What I would like to do is something along the lines of:
while(!my_future.is_ready()) tbb::task_scheduler::yield(); // If the calling context is inside an executing tbb task then run some other tasks.
tbb::task_scheduler::oversubscribe(true); // If the calling context is inside an executing tbb task then insert another thread into task-scheduler. my_future.wait(); tbb::task_scheduler::oversubscribe(false);
Is any of these or similar solutions possible with the current revision of tbb? Any suggestions in regards to work-arounds?