Skip to content

Modernize queue constraints, storage, and alignment for C++20 - #60

Merged
rigtorp merged 1 commit into
masterfrom
v2/02-cpp20
Nov 18, 2026
Merged

rigtorp merged 1 commit into
masterfrom
v2/02-cpp20

Conversation

@rigtorp

@rigtorp rigtorp commented Nov 18, 2026

Copy link
Copy Markdown
Owner

Summary

Second PR in the MPMCQueue 2.0 stack.

- SFINAE and body-level type checks
+ C++20 requires clauses and [[nodiscard]] on result-bearing operations
- Placement new and explicit destructor calls
+ std::construct_at and std::destroy_at
- Compiler-dependent false-sharing alignment
+ Architecture-specific kFalseSharingRange

Reuse the try_consume slot handoff in try_pop. Enqueue construction,
dequeue assignment, and the consume callback still need to be non-throwing.

Evidence

  • Before The slot layout depended on the compiler’s interference size, and
    dequeue could select a deleted move assignment despite a valid copy assignment.
  • After GCC Debug and Clang Release both passed MPMCQueueTest, including
    copy-only over-aligned elements, move-only elements, and try_consume.

Merge Danger

Door Two-way. Reverting restores the previous header implementation.

Blast radius Header consumers should rebuild together when upgrading
because the queue and slot layout may change. Ignored try-operation results
can now trigger [[nodiscard]] diagnostics.

@rigtorp
rigtorp merged commit fbb2570 into master Nov 18, 2026
8 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant