Multiple ChoiceIntermediate 45s
Double-Checked Locking with Atomics
To make double-checked locking correct in C++11+, the shared pointer must be:
Options
- 1A plain T* qualified volatile, which stops the compiler caching it
- 2A static local pointer written with no synchronization at all
- 3Protected by a recursive_mutex that both checks acquire on entry
- 4std::atomic<T*> with acquire/release (or std::call_once/once_flag)
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.