The C++ Explained Playlist: • C++ Benchmarking Explained: chrono, Clocks...
---
Chapters:
0:00 - The Problem: Why C++ STL Containers aren't Thread-Safe
0:48 - The Naive Producer-Consumer Implementation
1:54 - What is a Data Race? (Visualizing the Crash)
2:40 - Why std::queue::push is not atomic
3:54 - The "Time of Check to Time of Use" Bug
5:30 - Fixing the Crash: std::mutex and std::lock_guard
7:25 - RAII explained (Resource Acquisition Is Initialization)
10:15 - The New Problem: High CPU Usage (Busy Wait)
12:12 - Optimizing with std::condition_variable
14:39 - Switching to std::unique_lock (vs lock_guard)
15:42 - How cv.wait() actually works
16:53 - Spurious Wakeups & Predicates
19:00 - Refactoring: Building a ThreadSafeQueue Class
20:53 - The "Pop" Trap: Exception Safety & Return by Reference