Skip to content
TopicTracker
From HackerNewsView original
TranslationTranslation

Joys of cancelling a TBB task group

The article discusses the complexities and pitfalls of cancelling a task group in Intel's Threading Building Blocks (TBB) library, highlighting issues like race conditions and unexpected behavior when cancellation is not handled carefully. It provides code examples to illustrate how tasks can continue running or get stuck after a cancellation request.

Background

- **TBB (oneTBB)** — Intel's Threading Building Blocks, a popular C++ library for parallel programming. It handles tasks (units of work) and task groups (collections of tasks) across CPU cores. - **Task cancellation** — the ability to stop a group of tasks mid-execution (e.g., because results are no longer needed). The post details subtle bugs and edge cases that arise when attempting this in TBB's API. - The author (Aras Pranckevičius) is a veteran graphics/engine programmer at Unity Technologies, known for deep dives into low-level performance and concurrency issues. - Why it matters: cancellation seems simple but interacts dangerously with TBB's internal work-stealing scheduler; misusing it can cause hangs, crashes, or silently broken state — a cautionary tale for anyone doing modern C++ parallelism.