Intel® oneAPI Threading Building Blocks
Ask questions and share information about adding parallelism to your applications when using this threading library.
Announcements
This community is designed for sharing of public information. Please do not share Intel or third-party confidential information here.

tbb::task::spawn not execute

Sergey_M_2
Beginner
200 Views

tasks are created and properly executed, for N iterations of the task is not execute.

no exceptions.
what could be the problem? how to get the error?

 

class MyTask: public tbb::task
{
Function _f; //boost::function <void (tbb::task *)>
public:
MyTask(Function f) : _f(f) {}
~MyTask() {}
tbb::task * execute()
{
set_ref_count(1);
_f(this);
wait_for_all();
}
static Run(Function f)
{
MyTask& t = *new(allocate_root())t(f);
tbb::task::spawn(t);
}

0 Kudos
1 Reply
Anton_M_Intel
Employee
200 Views

Sergey M. wrote:

tbb::task * execute()
{
set_ref_count(1);
_f(this);
wait_for_all();
}
static Run(Function f)
{
MyTask& t = *new(allocate_root())t(f);
tbb::task::spawn(t);
}

Did you run it in debug configuration? It prints diagnostics if ref_count is misused (in _f).
The problem with non-executing tasks relates likely to missed wake-ups (e.g. as described here: http://software.intel.com/en-us/forums/topic/302353). And basically, it arises from the fact that you don't call required wait_for_all() after spawn().

Reply