aboutsummaryrefslogtreecommitdiffhomepage
path: root/include/grpc++
diff options
context:
space:
mode:
authorGravatar Yuxuan Li <yuxuanli@google.com>2017-03-27 13:25:33 -0700
committerGravatar Yuxuan Li <yuxuanli@google.com>2017-03-27 13:25:33 -0700
commite5ddd4b906b99781709b5f77b9c2b277df9d51c4 (patch)
tree952d948ec193722e76227ee2fb9a6e2d9608971c /include/grpc++
parent8d00f52d5b090585f4c66af0d17d359e5893ee5b (diff)
change EnsureInitialMetadataSent to use template
Diffstat (limited to 'include/grpc++')
-rw-r--r--include/grpc++/impl/codegen/async_stream.h50
1 files changed, 24 insertions, 26 deletions
diff --git a/include/grpc++/impl/codegen/async_stream.h b/include/grpc++/impl/codegen/async_stream.h
index c67e5e2247..8f529895ca 100644
--- a/include/grpc++/impl/codegen/async_stream.h
+++ b/include/grpc++/impl/codegen/async_stream.h
@@ -496,19 +496,6 @@ class ServerAsyncWriter final : public ServerAsyncWriterInterface<W> {
call_.PerformOps(&meta_ops_);
}
- void EnsureInitialMetadataSent(CallOpSetInterface* ops_in) {
- CallOpSet<CallOpSendInitialMetadata>* ops =
- static_cast<CallOpSet<CallOpSendInitialMetadata>*>(ops_in);
- if (!ctx_->sent_initial_metadata_) {
- ops->SendInitialMetadata(ctx_->initial_metadata_,
- ctx_->initial_metadata_flags());
- if (ctx_->compression_level_set()) {
- ops->set_compression_level(ctx_->compression_level());
- }
- ctx_->sent_initial_metadata_ = true;
- }
- }
-
void Write(const W& msg, void* tag) override {
write_ops_.set_output_tag(tag);
EnsureInitialMetadataSent(&write_ops_);
@@ -549,6 +536,18 @@ class ServerAsyncWriter final : public ServerAsyncWriterInterface<W> {
private:
void BindCall(Call* call) override { call_ = *call; }
+ template <class T>
+ void EnsureInitialMetadataSent(T* ops) {
+ if (!ctx_->sent_initial_metadata_) {
+ ops->SendInitialMetadata(ctx_->initial_metadata_,
+ ctx_->initial_metadata_flags());
+ if (ctx_->compression_level_set()) {
+ ops->set_compression_level(ctx_->compression_level());
+ }
+ ctx_->sent_initial_metadata_ = true;
+ }
+ }
+
Call call_;
ServerContext* ctx_;
CallOpSet<CallOpSendInitialMetadata> meta_ops_;
@@ -601,19 +600,6 @@ class ServerAsyncReaderWriter final
call_.PerformOps(&meta_ops_);
}
- void EnsureInitialMetadataSent(CallOpSetInterface* ops_in) {
- CallOpSet<CallOpSendInitialMetadata>* ops =
- static_cast<CallOpSet<CallOpSendInitialMetadata>*>(ops_in);
- if (!ctx_->sent_initial_metadata_) {
- ops->SendInitialMetadata(ctx_->initial_metadata_,
- ctx_->initial_metadata_flags());
- if (ctx_->compression_level_set()) {
- ops->set_compression_level(ctx_->compression_level());
- }
- ctx_->sent_initial_metadata_ = true;
- }
- }
-
void Read(R* msg, void* tag) override {
read_ops_.set_output_tag(tag);
read_ops_.RecvMessage(msg);
@@ -661,6 +647,18 @@ class ServerAsyncReaderWriter final
void BindCall(Call* call) override { call_ = *call; }
+ template <class T>
+ void EnsureInitialMetadataSent(T* ops) {
+ if (!ctx_->sent_initial_metadata_) {
+ ops->SendInitialMetadata(ctx_->initial_metadata_,
+ ctx_->initial_metadata_flags());
+ if (ctx_->compression_level_set()) {
+ ops->set_compression_level(ctx_->compression_level());
+ }
+ ctx_->sent_initial_metadata_ = true;
+ }
+ }
+
Call call_;
ServerContext* ctx_;
CallOpSet<CallOpSendInitialMetadata> meta_ops_;