Skip to content

refactor: consolidate MPSCQueue enqueue paths - #3655

Merged
wwbmmm merged 1 commit into
apache:masterfrom
songgaoye:refactor/mpsc-queue
Oct 25, 2026
Merged

wwbmmm merged 1 commit into
apache:masterfrom
songgaoye:refactor/mpsc-queue

Conversation

@songgaoye

Copy link
Copy Markdown
Contributor

What problem does this PR solve?

Issue Number: resolve

Problem Summary:

MPSCQueue<T>::Enqueue(const T&) and MPSCQueue<T>::Enqueue(T&&) duplicate
the node allocation and enqueue logic. The only behavioral difference is
whether the task value is copied or moved.

What is changed and the side effects?

Changed:

  • Extract the shared enqueue logic into a private forwarding helper.
  • Preserve copy semantics for lvalue inputs and move semantics for rvalue
    inputs.

Side effects:

  • No intended behavioral change.

  • Performance effects:

    No expected performance impact. Node allocation and queue operations are
    unchanged.

  • Breaking backward compatibility:

    No API or ABI changes.


Check List:

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 Approval recommended

The focused refactor preserves value categories, allocation, and synchronization, with no unresolved findings.

No open issues 🎉

What changed in this PR

Consolidates the duplicated MPSCQueue enqueue paths into a private forwarding helper without changing the public API or queue behavior.

Changes:

  • Shares node allocation, initialization, and enqueue logic between both overloads.
  • Preserves copy semantics for lvalues and move semantics for rvalues.
File Description
src/​butil/​containers/​mpsc_queue.h Adds EnqueueInternal and delegates both enqueue overloads to it.

Review effort: Balanced

@wwbmmm
wwbmmm merged commit bc6ce69 into apache:master Oct 25, 2026
29 checks passed
@songgaoye
songgaoye deleted the refactor/mpsc-queue branch October 25, 2026 10:30
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.

3 participants