Multiple-producer multiple-consumer
lastmod 2026-11-10created 2024-07-052 edits
Multiple-producer multiple-consumer (MPMC) is a queue concurrency model in which multiple threads push data and multiple threads pop data at the same time. Because both producers and consumers contend, it is the hardest of the four models to implement, and a lock-free implementation must deal with the ABA problem and memory reclamation together. It is used for general-purpose work queues and thread pools; if one side can be guaranteed to be a single thread, it is better to choose a simpler and faster model such as SPSC, SPMC, or MPSC.