Correctly implementing a spinlock in Modern C++
One neat thing is, you don&#x27;t actually need a spinlock if you&#x27;re using a ringbuffer. You can use atomic increment on a counter to claim a slot, then write to that slot.<p>It can be between two to three orders of magnitude higher throughput. Equally important, lower latency.<p>(Throughput tends to be a consequence of low latency, but not always.)<p>I&#x27;m not saying this should be the norm, though. You probably don&#x27;t need this design. But when you do, e.g. processing millions of stock market messages, there&#x27;s no substitute.<p>EDIT: I love hearing about the designs and questions, but it was probably a mistake for me not to be explicit. Sorry! The thing I&#x27;m referring to is LMAX Disruptor pattern: <a href="https:&#x2F;&#x2F;lmax-exchange.github.io&#x2F;disruptor&#x2F;" rel="nofollow">https:&#x2F;&#x2F;lmax-exchange.github.io&#x2F;disruptor&#x2F;</a><p>I learned about it in 2011-ish, and it deeply changed my perspective on high speed designs.