.learn() - page 8
what I have learned so far
-
atomic and the memory model
How is sharing without locks possible? std::atomic and CAS, reordering by the compiler and CPU, and the seq_cst, acquire/release, and relaxed memory orderings with happens-before.
-
Handling results with future, promise, and async
How do you get back the one result a thread computed? future/promise, which strips away the mutex+cv plumbing, std::async, packaged_task, and exception propagation across thread boundaries.
-
condition_variable and synchronisation patterns
How do you put a thread to sleep until a condition holds, and then wake it? The condition_variable that removes busy waiting, why lost and spurious wakeups are prevented, and the producer-consumer work queue.
-
Mutexes and RAII-based locking
Why does data break when several threads touch it at once? The mutex that prevents race conditions, exception-safe RAII locking (lock_guard and unique_lock), and shared_mutex, which distinguishes reads from writes.
-
Interfaces
An interface acts as the contract that governs how objects interact.