Community
cancel
Showing results for 
Search instead for 
Did you mean: 
irisshinra308
Beginner
45 Views

allocate_continuation problem

Hello~

I am trying to understand the allocate_continuation source code lately.
It seems that it simply call the allocate_task to allocate a new task entity and return it.
However, the continuation task is not inserted into the task pool or mailbox via the spawn() function.
My question is, would TBB put the continuation task into the task pool?
If the continuation task's affinity id is not zero, would TBB put this task into the mailbox?

Any help would be grateful!

Dennis

0 Kudos
4 Replies
RafSchietekat
Black Belt
45 Views

"Any help would be grateful!"
What documentation have you consulted?

Basically, a continuation is implicitly spawned when "its" children finish executing. I have not yet looked into the affinity issues.
Alexey_K_Intel3
Employee
45 Views

Quoting - irisshinra308
My question is, would TBB put the continuation task into the task pool?
If the continuation task's affinity id is not zero, would TBB put this task into the mailbox?

As Raf correctly noted, a continuation task should be executed when its children completed. The thread that executed the "last" child (which means, decremented reference counter to 0) will either execute the continuation or spawn it to the own pool, depending on whether it has another task to execute "at hands". Most likely, the continuation task will be executed directly. But in case it does go to the pool, usual task-to-thread affinity rules are applied.

Also note that all this is the current implementation detail and may change.
irisshinra308
Beginner
45 Views


The thread that executed the "last" child (which means, decremented reference counter to 0) will either execute the continuation or spawn it to the own pool, depending on whether it has another task to execute "at hands". Most likely, the continuation task will be executed directly. But in case it does go to the pool, usual task-to-thread affinity rules are applied.

Thanks for the reply.

In most cases, a continuation task would be executed directly after the last child execution, but in some other cases, it could be put into the task pool and mailbox if needed. Am I right?

I thought this might be implemented in the wait_for_all(), and it seems that the switch case task::executing internally spawned the continuation task, right?

Thanks again

Dennis

RafSchietekat
Black Belt
45 Views

Apparently not a basic question after all... But why do you want to know this? BTW, a related question could be what happens if one of the children returns a pointer to the continuation.