Intel® oneAPI Threading Building Blocks
Ask questions and share information about adding parallelism to your applications when using this threading library.

A basic question on task reference count

chentianran
Beginner
127 Views
I still have trouble understanding the role of task reference count: suppose a parent task created 3 children task and wait for them to finish, then according to the examples, I should set the reference count of the parent task to 3+1=4. But what if I want to have the parent task discarded as soon as it spawns the children tasks, how should I set its reference counter? I'm thinking 0. Wrong answer?
0 Kudos
1 Reply
RafSchietekat
Black Belt
127 Views
Then they should be root tasks instead of child tasks, so they won't try to decrement a reference count that no longer exists, and quite likely you might want to enqueue them instead, but that's difficult to say without knowing why you would want the creating task to be discarded (have you considered a continuation instead?).
Reply