All challenges
Multiple ChoiceBeginner 45s

atomic bool spin vs condition_variable

When is a condition_variable generally preferred over spinning on a std::atomic<bool>?
Options
  1. 1When the flag must be lock-free at all costs
  2. 2When the wait duration may be long, to avoid burning CPU
  3. 3When you need sub-nanosecond wakeup latency
  4. 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.

Play this in a 3-minute battle