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

   ### What problem does this PR solve?
   
   Issue Number: resolve
   
   Problem Summary:
   
   `ExecutionQueue<T>::execute(const T&, ...)` casts its const lvalue input to
   `T&` and forwards it as `T&&`. As a result, submitting an lvalue can invoke
   `T`'s move constructor and unexpectedly modify the caller's object.
   
   ### What is changed and the side effects?
   
   Changed:
   
   - Replace the `const_cast`-based forwarding path with an internal forwarding
     helper.
   - Preserve copy semantics for lvalue tasks and move semantics for rvalue 
tasks.
   - Add a regression test verifying that submitting an lvalue does not move 
from
     it.
   
   Side effects:
   
   - Lvalue task submissions now consistently copy the task, as implied by the
     `const T&` API.
   - Rvalue task submissions retain their existing move behavior.
   
   - Performance effects:
   
     No expected impact on rvalue submissions. Lvalue submissions now avoid
     unintended moves and follow the intended copy path.
   
   - Breaking backward compatibility:
   
     No API or ABI changes. Code that unintentionally relied on an lvalue being
     moved from will observe the corrected behavior.
   
   ---
   ### 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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to