Community
cancel
Showing results for 
Search instead for 
Did you mean: 
andreyryabov
Beginner
68 Views

question on task::spawn

When I call task::spawn does It mean that some other thread can execute this just spawned task before I spawn any other sibling task? If not when tasks become eligible for execution?
0 Kudos
3 Replies
andreyryabov
Beginner
68 Views

I'm confused by an advice given on page 168 of Thread Building Blocks book. It says "Allocate all siblings before of them starat to run, unless you are using allocate_additional_child_of". How shold I understend it? And how to acheive it. tbb does not allow to control when tasks starts running.
Alexey_K_Intel3
Employee
68 Views

Quoting - andreyryabov
I'm confused by an advice given on page 168 of Thread Building Blocks book. It says "Allocate all siblings before of them starat to run, unless you are using allocate_additional_child_of". How shold I understend it? And how to acheive it. tbb does not allow to control when tasks starts running.

As soon as you spawn a task you have no control over when it starts running, so you might just assume it already runs, or even finished.

That advice in the book, however, is too strong. Actually you can mix task allocation and spawns, as long as you appropriately set the reference counter before spawning any sibling task. Read the TBB Reference document, chapter 8.8 "Catalog of Recommended Task Patterns" for more detailed information of how the TBBtasks are supposed to use.
andreyryabov
Beginner
68 Views


As soon as you spawn a task you have no control over when it starts running, so you might just assume it already runs, or even finished.

That advice in the book, however, is too strong. Actually you can mix task allocation and spawns, as long as you appropriately set the reference counter before spawning any sibling task. Read the TBB Reference document, chapter 8.8 "Catalog of Recommended Task Patterns" for more detailed information of how the TBBtasks are supposed to use.

Great!
Thank you!
Reply