Multiple ChoiceBeginner 45s
atomic bool spin vs condition_variable
When is a condition_variable generally preferred over spinning on a std::atomic<bool>?
Options
- 1When the flag must be lock-free at all costs
- 2When the wait duration may be long, to avoid burning CPU
- 3When you need sub-nanosecond wakeup latency
- 4Never; spin loops are always faster
Think you can answer under pressure?
Get matched and answer live questions in 3-minute 1v1 battles. Elo ranking, badge tiers and bragging rights on the line.