Price your future right. 60% off with code BLACKSCHOLES at USD checkout. Offer ends in 8d 09h 54m 30s8 days 9 hours 54 minutes 30 seconds.
Price your future right. 60% off with code BLACKSCHOLES at USD checkout. Offer ends in 8d 09h 54m 30s8 days 9 hours 54 minutes 30 seconds.

Sign in to watch this lesson
Races and Locks · 4:34
The tools for locking exactly as much as you need: std::unique_lock (defer, unlock early, move a lock out of a function), short critical sections, std::call_once and function-local statics instead of double-checked locking, and std::shared_mutex for readers and writers. Every claim is measured on an Apple M3: unlocking before a microsecond of private work made eight threads about four times faster, Listing 3.10's one-lock-at-a-time operator== reported 'equal' for values that never coexisted, ThreadSanitizer flagged double-checked locking, and shared_mutex lost on tiny reads but won about threefold on long ones.