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

Sign in to watch this lesson
Races and Locks · 4:17
Why a stack that locks a mutex in every member function can still lose data: the answer from empty() or top() goes stale the moment the lock is released, so check-then-act sequences race between calls. On an Apple M3, eight threads draining a million values processed about seventeen thousand twice and lost as many, with ThreadSanitizer silent. We then see why std::stack splits top() from pop() (Cargill's exception problem) and fix the interface with one pop() that checks, reads and removes under a single lock.