Community
cancel
Showing results for 
Search instead for 
Did you mean: 
pedro_p_3
Beginner
41 Views

Task seemingly dropped

Hi there,

I am using TBB 4.1 in production and I have recently came across a problem that *seems* to indicate that on occasion tasks can be dropped without every being executed. I am using the following call to spawn a task:

      auto &task = *new(tbb::task::allocate_root()) DrainMailbox(*me, this);
      LOG << "Spawning " << &task;
      tbb::task::spawn(task);

And inside the task I log as follows:

struct TBBMailbox::DrainMailbox : public tbb::task 
{   
   DrainMailbox (TBBMailbox::PImpl &me, TBBMailbox const *ptr)
      : me (me), mbox_ptr (ptr)
   {}
   
   tbb::task* execute () 
   {
      LOG  << " task: " << this << " executing";
      

...

On occasion I see the "spawn" log entry but not the corresponding "executing" log entry (other tasks are still being spawned and executed - so I know TBB has enough non blocked threads to work with). 

Any ideas on what could be going wrong? This is in on Linux x64, 3.13. 

Thanks in advance

 

 

 

0 Kudos
1 Reply
RafSchietekat
Black Belt
41 Views

If you want to "fire and forget" a task, use enqueue() rather than spawn(). Otherwise you could explicitly spawn_root_and_wait().

Reply