---
title: "Discussion on \"C++ Lock-Free Queue - Part II\" | Hashnode"
description: "Discussion on \"C++ Lock-Free Queue - Part II\". In Part I of this blog series, we discussed how to write a lock-free queue for the case of a single producer thread and a single consumer thread (SPSC). This is handy when sending messages between dedicated threads, but we often want to have multiple..."
url: "https://hashnode.com/posts/c-lock-free-queue-part-ii/651a5e0e0b40966cba661f63"
---

[Feed](https://hashnode.com/feed) /

Discussion

# [C++ Lock-Free Queue - Part II](https://radiantsoftware.hashnode.dev/c-lock-free-queue-part-ii?utm_source=hashnode&utm_medium=feed)

In Part I of this blog series, we discussed how to write a lock-free queue for the case of a single producer thread and a single consumer thread (SPSC). This is handy when sending messages between dedicated threads, but we often want to have multiple...

Oct 2, 2023 · 16 min read · radiantsoftware.hashnode.dev  
Updated Oct 31, 2023  
Read the article

-   [#cpp](https://hashnode.com/tag/cpp)
-   [#lock-free](https://hashnode.com/tag/lock-free)
-   [#queue](https://hashnode.com/tag/queue)
-   [#multithreading](https://hashnode.com/tag/multithreading)
-   [#game-development](https://hashnode.com/tag/game-development)

## Written by

[Paul Mattione](https://hashnode.com/@radiantsoftware)

@radiantsoftware · Bethesda, MD

  
[View profile](https://hashnode.com/@radiantsoftware)

Principal Engine Programmer @ Volition Games

I'm a Principal Programmer working on the Engine Team at Volition Games! The content of this blog is my own, personal work and views, and is not endorsed by any other party.

## Responses 1

Markdown supported · ⌘↵ to post

[Andrew Michell](https://hashnode.com/@amich239)

[Apr 14, 2025](https://hashnode.com/posts/c-lock-free-queue-part-ii/651a5e0e0b40966cba661f63/comment/67fd3ea08052c5351da22005)

Hi Paul, excellent post! I wrote a Reserve\_PopSlot function that closely resembles Reserve\_EmplaceSlot and added some tests. SPSC, MPSC, SPMC all work great, however I'm running into an issue with MPMC consumer thinking that the queue is empty because cIndices.mUnwrappedPushIndex == cIndices.mUnwrappedPopIndex but mSize is not 0. Have you experienced this?... If you send me your email I can respond with my implementation of Reserve\_PopSlot. Thank you!

[Paul Mattione](https://hashnode.com/@radiantsoftware)

[Jun 13, 2025](https://hashnode.com/posts/c-lock-free-queue-part-ii/651a5e0e0b40966cba661f63/comment/67fd3ea08052c5351da22005#reply-684b6b26cff69426dd88cbe2)

Sorry I didn't see this until now! I've been really slammed lately. I have recently made my source code publicly available (for viewing only, not for copy or use yet), so you compare yours against it and see what might be different: [bitbucket.org/RadiantSoftware/engine/src/master/C…](https://bitbucket.org/RadiantSoftware/engine/src/master/Core/Containers/AtomicQueue.impl)
