Thread-Safe Queues
From one mutex to many producers: condition variables and lost wakeups in a blocking queue, rte_ring’s two pairs of indices and in-order publishing, Disruptor’s availability flags, and whether a full queue should block, drop, or …
Tags
5 posts
From one mutex to many producers: condition variables and lost wakeups in a blocking queue, rte_ring’s two pairs of indices and in-order publishing, Disruptor’s availability flags, and whether a full queue should block, drop, or …
Wait-free is not a faster lock-free: it turns a failed CAS from “try again” into “I come after you”, which bounds every thread’s steps, at the cost of more atomics and code that is harder to get right.
There are three ways to get data into cache ahead of time, each with a precondition: prefetching needs you to know the address before the hardware does, warming has to happen on the core that reads the data, and double buffering …
Market data has one producer and several consumers, each of which must see every message, and the producer is the hot path that may not wait for anyone. The answer is a broadcast ring: every slot carries its own sequence stamp, …
A lock-free SPSC queue works because every shared variable has exactly one writer: each side updates only its own counter and merely reads the other’s. The rest is keeping that property from being quietly undone — a shared element …
