class MyTask : public tbb::task
{
public:
virtual tbb::task* execute()
{
// ... do work ...
if (!isDone())
{
recycle_as_safe_continuation();
set_ref_count(1);
// Task starvation?
// return this;
}
return 0;
}
private:
bool isDone() const { ... }
}
My question is regarding the behavior or returning 0 versus this after recycling the task. The scheduling documentation states that returning a task bypasses the scheduler, and the thread will execute the returned task next. If all the active worker threads are executing such self re-executing tasks, and they all return themselves as the next task, does this mean that the scheduler will starve any/all other tasks in the ready pool(s) for as long as the active tasks aren't done? Alternatively, if I return 0 instead, are other threads free to steal the task, or does the non-zero refcount prevent that?
1 reply to this topic
#1 Crossbones+ - Reputation: 402
Posted 26 October 2012 - 07:11 PM
I haven't been able to find much information on the net pertaining to a particular usage pattern of TBB tasks, wherein the task recycles itself so it can be executed again, in my case for some extended period of time:
Sponsor:
#2 Crossbones+ - Reputation: 3416
Posted 26 October 2012 - 08:32 PM
I have absolutely no answer to your question. But I wanted to say, Welcome back! Long time no see.
Beginner in Game Development? Read here.
Super Mario Bros clone tutorial written in XNA 4.0 [MonoGame, ANX, and MonoXNA] by Scott Haley
If you have found any of the posts helpful, please show your appreciation by clicking the up arrow on those posts ![]()
Spoiler






