Skip to content

The MPSC queue should move the rvalue-reference argument into data_mem init - #3627

Merged
chenBright merged 3 commits into
apache:masterfrom
ehds:hds/fix_mpsc_move_and_destrory
Oct 20, 2026
Merged

chenBright merged 3 commits into
apache:masterfrom
ehds:hds/fix_mpsc_move_and_destrory

Conversation

@ehds

@ehds ehds commented Oct 19, 2026

Copy link
Copy Markdown
Contributor

What problem does this PR solve?

Issue Number: resolve

Problem Summary:

Without std::move, data is passed to Init as an lvalue, In this case, the move constructor will not be called. And for move-only type, this call will not compile.

What is changed and the side effects?

Changed:
std::move(data) is required to move-construct data_mem.

Side effects:

  • Performance effects:

  • Breaking backward compatibility:


Check List:

@chenBright
chenBright requested a lite review from Copilot October 19, 2026 15:35

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.

Warning

Copilot couldn't run its full agentic review because it didn't start before the timeout. Make sure your repository has a runner available, or add a copilot-code-review.yml file specifying one with the runs-on attribute. See the docs for more details.

Copilot review overview

1 open issue
What changed in this PR

This PR fixes MPSCQueue::Enqueue(T&&) so rvalue arguments are actually moved into the node storage, enabling move-only element types and avoiding unintended copies.

Changes:

  • Move-construct data_mem by passing std::move(data) to Init in Enqueue(T&&).
  • Add a unit test that enqueues a std::unique_ptr<int> to validate move-only support.
File Description
test/​mpsc_queue_unittest.cc Adds coverage to ensure move-only types can be enqueued.
src/​butil/​containers/​mpsc_queue.h Fixes rvalue enqueue to forward as a move into node storage.

Review effort: Lite

Comment thread test/mpsc_queue_unittest.cc
Added test for enqueueing and dequeuing move-only types in MPSCQueue.

Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
@chenBright
chenBright requested a lite review from Copilot October 19, 2026 16:27

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.

Warning

Copilot couldn't run its full agentic review because it didn't start before the timeout. Make sure your repository has a runner available, or add a copilot-code-review.yml file specifying one with the runs-on attribute. See the docs for more details.

Copilot review overview

No open issues 🎉

1 resolved since last review

Review effort: Lite

@chenBright chenBright 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.

LGTM

@chenBright
chenBright merged commit 3c55907 into apache:master Oct 20, 2026
25 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.

3 participants