C++ Structured Concurrency
11 Nov 2026
[
c++
concurrency
development
]
Summary
- Concurrent systems can handle complex scenarios of incoming events
- Achieving high performance can mean eliminating helper facilities like threads, stacks and even heap allocations
- Older approaches are error prone and require attention to details
- Managing object lifetime
- Handling complex scenarios
- Errors and cancelation.
- Structured concurrency is a composable low-overhead approach
- Both coroutines and the senders (std::execution) frameworks provide structured concurrency
- Both frameworks interoperate - we don’t have to choose one.
Tips
- Import an existing library, don’t start from scratch
- Keep control of your main-loop if possible
How to start
- Try coroutines
- Already in the standard
- Quite a few libraries exist.
- If current code is non-blocking: consider starting from the root, not leaf
- start by changing
return to co_return, then consider where to co_await.
- If current code is blocking (threads): go from leafs towards to root
- function-coloring is an issue - be creative.
- Don’t fear cancellation
- If some old code needs to interact with a suspended coroutine - consider cancellation
- Alternatively be creative with the
co_await return type (std::expected ?)
References