You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Avoid copying OpSendMsg when sending messages (apache#308)
Fixesapache#306
### Motivation
`OpSendMsg` is a struct whose size is 400 bytes. We should avoid the
copy operation on it.
### Modifications
Pass the `unique_ptr<OpSendMsg>` everywhere instead of `OpSendMsg`.
- Use `unique_ptr<OpSendMsg>` as the element of the pending message
queue in `ProducerImpl` and disable the copy constructor and
assignment for `OpSendMsg`.
- Add `SendArgument`, which includes the necessary fields to construct a
`CommandSend` request. Use `shared_ptr` rather than `unique_ptr` to
store `SendArgument` in `OpSendMsg` because the producer might need to
resend the message so the `SendArgument` object could be shared by
`ProducerImpl` and `ClientConnection`.
This patch is more like a refactor because the compiler optimization
might reduce unnecessary copying.
0 commit comments