Understanding std::async execution models in C++
This easy concurrency question tests your grasp of how std::async actually behaves — a critical detail that trips up even experienced C++ candidates. It probes whether you understand the difference between launch policies and the practical consequences for your code's execution order and timing.
The question asks you to observe and reason about std::async's default behaviour, including when tasks actually run (immediately, deferred, or on a thread pool), when they block, and what output results. This matters at quant shops because async task scheduling bugs can silently break latency assumptions and introduce subtle race conditions.
- Launch policies: std::launch::async vs. std::launch::deferred vs. default
- Destructor behavior of std::future and blocking semantics
- Execution order and visibility across threads
- When code actually runs vs. when you think it runs