tbb::task cancellation

tbb::task cancellation


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?

//Bjrn Tpel

4 posts / 0 new
Last post
For more complete information about compiler optimizations, see our Optimization Notice.

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.

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.



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

- Arch

Leave a Comment

Please sign in to add a comment. Not a member? Join today