Theme 1 – Spinlocks are usually an anti‑pattern, but can be justified in narrow, measured cases
- “I don’t recommend spinlock for most cases, only when there is a 1:1 mapping between threads and physical CPU cores, and only after measuring” – dalvrosa
- “I was always told that they were an anti‑pattern … there are always exceptions to ‘good rules of thumb’” – tombert
Theme 2 – Real‑world codebases do use spinning techniques
- “Go stdlib sync.Mutex uses spins” – ignoramous (link to Go mutex blog)
- “I genuinely had not heard of anyone actually using a spinlock in production code until I started using LMAX Disruptor …” – tombert
Theme 3 – Effectiveness depends on hardware and the exact synchronization primitive
- “To be really pedantic, it’s a spin wait, not a spin lock in disruptor…” – bob1029 (distinguishing spin‑wait from a true lock)
- “This would have different answers depending on if it ran on a machine with a more closely‑shared cache…” – jeffbee
- “not all architectures have atomic cas” – mathisfun123 (hardware prerequisite)