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

tbb::task cancellation

bjoto
Beginner
574 Views
Hi,

What is the best/recommended way of cancelling a tbb::task after it has been spawned? As far as I can see, this is not possible without waiting for the task execute() to complete.

If not cancellation is supported, what was the design decision for this?

Cheers,
//Bjrn Tpel


0 Kudos
3 Replies
ARCH_R_Intel
Employee
574 Views

Task cancellation was left out of the original design because we didn't have enough experience to guide us on doing it right. Now that we have experience, we're working on task cancellation and exception-safe tasks and have a design that seems towork well for both.

For now, the best way is to have the task poll a shared cache line. My blog http://softwareblogs.intel.com/2007/11/08/have-a-fish-how-break-from-a-parallel-loop-in-tbb/explains how to do this in the context of parallel_for by defining a cancelable_range object that "collapses" when the loop is cancelled.

0 Kudos
bjoto
Beginner
574 Views
Interresting! Do you have a time frame when we can expect the cancellation functionality to appear in a developer release?

Thanks for the blog pointer.

Cheers,
//Bjrn
0 Kudos
ARCH_R_Intel
Employee
574 Views

End of January 2008 is the current target for puttingcancellation/exception-safe tasks in the developer release.

- Arch

0 Kudos
Reply