You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@brpc.apache.org by "ehds (via GitHub)" <gi...@apache.org> on 2026/10/19 14:49:53 UTC

[PR] The MPSC queue should move the rvalue-reference argument into data_mem init (brpc)

ehds opened a new pull request, #3627:
URL: https://github.com/apache/brpc/pull/3627

   ### 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:
   - Please make sure your changes are compilable.
   - When providing us with a new feature, it is best to add related tests.
   - Please follow [Contributor Covenant Code of Conduct](https://github.com/apache/brpc/blob/master/CODE_OF_CONDUCT.md).
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: dev-unsubscribe@brpc.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@brpc.apache.org
For additional commands, e-mail: dev-help@brpc.apache.org


Re: [PR] The MPSC queue should move the rvalue-reference argument into data_mem init (brpc)

Posted by "Copilot (via GitHub)" <gi...@apache.org>.
Copilot commented on code in PR #3627:
URL: https://github.com/apache/brpc/pull/3627#discussion_r4315921628


##########
test/mpsc_queue_unittest.cc:
##########
@@ -158,6 +158,11 @@ TEST(MPSCQueueTest, destroys_dequeued_element) {
     ASSERT_EQ(0, DestructionTracked::alive);
 }
 
+TEST(MPSCQueueTest, enqueue_move_only) {
+  butil::MPSCQueue<std::unique_ptr<int>> q;
+  q.Enqueue(std::make_unique<int>(1));

Review Comment:
   This test only checks compilation and does not assert runtime behavior. To better cover the move-only enqueue path, consider also dequeuing the element and asserting it is non-null and holds the expected value (e.g., `*ptr == 1`), or otherwise verifying the queue size/emptiness transitions if those APIs exist.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: dev-unsubscribe@brpc.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@brpc.apache.org
For additional commands, e-mail: dev-help@brpc.apache.org


Re: [PR] The MPSC queue should move the rvalue-reference argument into data_mem init (brpc)

Posted by "chenBright (via GitHub)" <gi...@apache.org>.
chenBright merged PR #3627:
URL: https://github.com/apache/brpc/pull/3627


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: dev-unsubscribe@brpc.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@brpc.apache.org
For additional commands, e-mail: dev-help@brpc.apache.org