What I'm trying to do is create a task hierarchy by creating a task in one class that will eventually call tasks in another class. Initially I set every task to be a root task and then used "spawn_and_wait" which enabled me to pass a task_group_context around to cancel execution. As soon as I converted to only using one root along with continuation and child tasks, I'm consistently getting invalid task_group_context errors:
Module: tbb_debug.dll File: ../../src/tbb/scheduler.h Line: 458 Expression: !(ctx&~(3|7(<<task_group_context::traits_ofset))) task_group_context is invalid
I have tried both of the following scenarios. Scenario 1 is faster but neither works with a task_group_context created at the start.
Scenario 1: Two Root Tasks of Different Type ============================================ Class A * creates a task_group_context * spawns a task 1 (allocate_root) passing in context * execute method calls a function in Class B passing the same context Class B * spawns a task 2 (allocate_root) using the passed in context <== second root task * execute of task 2 spawns a task 3 as a continuation and task 4 as a child Scenario 2: Two Continuation Tasks of Different Type ===================================================== Class A * creates a task_group_context * spawns a task 1 (allocate_root) passing in context * execute method calls a function in Class B passing a "this" pointer Class B * spawns a task 2 (allocate_continuation) <== now a continuation of task 1 rather than a separate root * execute of task 2 spawns a task 3 also as a continuation and task 4 as a child
I suppose my questions boil down to the following:
- Is it wise to have multiple tasks allocated as root in a task hierarchy?
- If the approach is to only have one root task, what is the best way to spawn continuation and child tasks in a different class that shares the same task_group_context?
Any guidance is appreciated. Thanks.