Merge pull request #24527 from vjpai/call_op_set_codesize

Remove redundant code paths in call_op_set.h
pull/24520/head
Vijay Pai 4 years ago committed by GitHub
commit f6d59d7c06
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 48
      include/grpcpp/impl/codegen/call_op_set.h

@ -330,6 +330,7 @@ class CallOpSendMessage {
}
void FinishOp(bool* status) {
if (msg_ == nullptr && !send_buf_.Valid()) return;
send_buf_.Clear();
if (hijacked_ && failed_send_) {
// Hijacking interceptor failed this Op
*status = false;
@ -378,9 +379,33 @@ class CallOpSendMessage {
template <class M>
Status CallOpSendMessage::SendMessage(const M& message, WriteOptions options) {
write_options_ = options;
// Serialize immediately since we do not have access to the message pointer
bool own_buf;
// TODO(vjpai): Remove the void below when possible
// The void in the template parameter below should not be needed
// (since it should be implicit) but is needed due to an observed
// difference in behavior between clang and gcc for certain internal users
Status result = SerializationTraits<M, void>::Serialize(
message, send_buf_.bbuf_ptr(), &own_buf);
if (!own_buf) {
send_buf_.Duplicate();
}
return result;
}
template <class M>
Status CallOpSendMessage::SendMessage(const M& message) {
return SendMessage(message, WriteOptions());
}
template <class M>
Status CallOpSendMessage::SendMessagePtr(const M* message,
WriteOptions options) {
msg_ = message;
write_options_ = options;
// Store the serializer for later since we have access to the message
serializer_ = [this](const void* message) {
bool own_buf;
send_buf_.Clear();
// TODO(vjpai): Remove the void below when possible
// The void in the template parameter below should not be needed
// (since it should be implicit) but is needed due to an observed
@ -392,31 +417,12 @@ Status CallOpSendMessage::SendMessage(const M& message, WriteOptions options) {
}
return result;
};
// Serialize immediately only if we do not have access to the message pointer
if (msg_ == nullptr) {
Status result = serializer_(&message);
serializer_ = nullptr;
return result;
}
return Status();
}
template <class M>
Status CallOpSendMessage::SendMessage(const M& message) {
return SendMessage(message, WriteOptions());
}
template <class M>
Status CallOpSendMessage::SendMessagePtr(const M* message,
WriteOptions options) {
msg_ = message;
return SendMessage(*message, options);
}
template <class M>
Status CallOpSendMessage::SendMessagePtr(const M* message) {
msg_ = message;
return SendMessage(*message, WriteOptions());
return SendMessagePtr(message, WriteOptions());
}
template <class R>

Loading…
Cancel
Save