Revisiting C++ Observers: Spooky Action at a Distance
summary
Reexamines concrete Observer implementations in C++ and shows why no one recipe survives real code: uses a std::vector of raw pointers, lazy-initialized containers, a global unordered_map registry, deferred cleanup (mark-as-null then sweep), copying the observer list under lock to broadcast, and a proxy with non-type tag to disambiguate overloads. Demonstrates recursive remove, thread races, and deadlocks with mutexes, argues for copying/value semantics over heavy locking, and concludes there is no universal library solution — pick minimal, documented policies for your workload.
AI-written summary · about
chapters (18)
- 0:00Spooky action introduction
- 2:12C++ design patterns critique
- 6:51Observer vocabulary
- 9:18Trivial registration
- 12:53Local reasoning with observers
- 19:35Order sensitivity in notifications
- 23:12Broadcasting notifications
- 26:20Recursive deregistration
- 29:55Intrusive vs non-intrusive
- 35:17Thread safety challenges
- 43:07Value semantics in observers
- 48:29Deferred deletion thread safety
- 51:45Robust observer impossibility
- 53:11Actor facade for boilerplate
- 59:15Disambiguating events with tags
- 1:08:50Reusable observer proxies
- 1:11:44Observer networks as state
- 1:13:32Q&A
related talks
01h 03mSpooky Action at a Distance
01h 02mThe Observer Design Pattern in Cpp
04mUsing a Smart Event Dispatcher in C++
33mThe Observer tip-jar
05mobserve me not - a short story about smart pointers
55mC++ Concurrency TS 2 Use Cases and Future Direction
55mHow to "OO" in C++
51mThe Smart Pointers I Wish I Had
