[EMCpp]Item-37 Make std::threads Unjoinable on All Paths
· ☕ 3 min read
Join-on-destruction can lead to difficult-to-debug performance anomalies; while detach-on-destruction can lead to difficult-to-debug undefined behavior.
Join-on-destruction can lead to difficult-to-debug performance anomalies; while detach-on-destruction can lead to difficult-to-debug undefined behavior.
The flexibility that default policy for std::async
permits both async and sync task execution leads to uncertainty when accessing thread_locals
, implies that the task may never execute, and affects program logic for timeout-based wait
calls.
Thread-based programming calls for manual management of thread exhaustion, oversubscription, load balancing, and adaptation to new platforms, while task-based programming via std::async
with the default launch policy handles most of the issues for us.