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?
Zipster
Member Since 11 Mar 2000Offline Last Active Yesterday, 12:05 PM

Find content
Not Telling