Imported Upstream version 1.41.0
[platform/upstream/grpc.git] / include / grpcpp / impl / codegen / async_stream.h
index f957726..db5b374 100644 (file)
@@ -1,6 +1,6 @@
 /*
  *
- * Copyright 2015 gRPC authors.
+ * Copyright 2019 gRPC authors.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  * See the License for the specific language governing permissions and
  * limitations under the License.
- *
  */
 
 #ifndef GRPCPP_IMPL_CODEGEN_ASYNC_STREAM_H
 #define GRPCPP_IMPL_CODEGEN_ASYNC_STREAM_H
 
+// IWYU pragma: private, include <grpcpp/support/async_stream.h>
+
 #include <grpcpp/impl/codegen/call.h>
 #include <grpcpp/impl/codegen/channel_interface.h>
 #include <grpcpp/impl/codegen/core_codegen_interface.h>
@@ -51,7 +52,7 @@ class ClientAsyncStreamingInterface {
   /// when the call has been ended.
   /// Should not be used concurrently with other operations.
   ///
-  /// It is appropriate to call this method when both:
+  /// It is appropriate to call this method exactly once when both:
   ///   * the client side has no more message to send
   ///     (this can be declared implicitly by calling this method, or
   ///     explicitly through an earlier call to the <i>WritesDone</i> method
@@ -74,7 +75,7 @@ class ClientAsyncStreamingInterface {
   ///
   /// \param[in] tag Tag identifying this request.
   /// \param[out] status To be updated with the operation status.
-  virtual void Finish(Status* status, void* tag) = 0;
+  virtual void Finish(::grpc::Status* status, void* tag) = 0;
 };
 
 /// An interface that yields a sequence of messages of type \a R.
@@ -134,7 +135,7 @@ class AsyncWriterInterface {
   /// \param[in] msg The message to be written.
   /// \param[in] options The WriteOptions to be used to write this message.
   /// \param[in] tag The tag identifying the operation.
-  virtual void Write(const W& msg, WriteOptions options, void* tag) = 0;
+  virtual void Write(const W& msg, ::grpc::WriteOptions options, void* tag) = 0;
 
   /// Request the writing of \a msg and coalesce it with the writing
   /// of trailing metadata, using WriteOptions \a options with
@@ -154,7 +155,7 @@ class AsyncWriterInterface {
   /// \param[in] msg The message to be written.
   /// \param[in] options The WriteOptions to be used to write this message.
   /// \param[in] tag The tag identifying the operation.
-  void WriteLast(const W& msg, WriteOptions options, void* tag) {
+  void WriteLast(const W& msg, ::grpc::WriteOptions options, void* tag) {
     Write(msg, options.set_last_message(), tag);
   }
 };
@@ -178,13 +179,13 @@ class ClientAsyncReaderFactory {
   /// Note that \a context will be used to fill in custom initial metadata
   /// used to send to the server when starting the call.
   template <class W>
-  static ClientAsyncReader<R>* Create(ChannelInterface* channel,
-                                      CompletionQueue* cq,
+  static ClientAsyncReader<R>* Create(::grpc::ChannelInterface* channel,
+                                      ::grpc::CompletionQueue* cq,
                                       const ::grpc::internal::RpcMethod& method,
-                                      ClientContext* context, const W& request,
-                                      bool start, void* tag) {
+                                      ::grpc::ClientContext* context,
+                                      const W& request, bool start, void* tag) {
     ::grpc::internal::Call call = channel->CreateCall(method, context, cq);
-    return new (g_core_codegen_interface->grpc_call_arena_alloc(
+    return new (::grpc::g_core_codegen_interface->grpc_call_arena_alloc(
         call.call(), sizeof(ClientAsyncReader<R>)))
         ClientAsyncReader<R>(call, context, request, start, tag);
   }
@@ -198,8 +199,8 @@ template <class R>
 class ClientAsyncReader final : public ClientAsyncReaderInterface<R> {
  public:
   // always allocated against a call arena, no memory free required
-  static void operator delete(void* ptr, std::size_t size) {
-    assert(size == sizeof(ClientAsyncReader));
+  static void operator delete(void* /*ptr*/, std::size_t size) {
+    GPR_CODEGEN_ASSERT(size == sizeof(ClientAsyncReader));
   }
 
   // This operator should never be called as the memory should be freed as part
@@ -207,10 +208,10 @@ class ClientAsyncReader final : public ClientAsyncReaderInterface<R> {
   // delete to the operator new so that some compilers will not complain (see
   // https://github.com/grpc/grpc/issues/11301) Note at the time of adding this
   // there are no tests catching the compiler warning.
-  static void operator delete(void*, void*) { assert(0); }
+  static void operator delete(void*, void*) { GPR_CODEGEN_ASSERT(false); }
 
   void StartCall(void* tag) override {
-    assert(!started_);
+    GPR_CODEGEN_ASSERT(!started_);
     started_ = true;
     StartCallInternal(tag);
   }
@@ -224,7 +225,7 @@ class ClientAsyncReader final : public ClientAsyncReaderInterface<R> {
   ///     calling code can access the received metadata through the
   ///     \a ClientContext.
   void ReadInitialMetadata(void* tag) override {
-    assert(started_);
+    GPR_CODEGEN_ASSERT(started_);
     GPR_CODEGEN_ASSERT(!context_->initial_metadata_received_);
 
     meta_ops_.set_output_tag(tag);
@@ -233,7 +234,7 @@ class ClientAsyncReader final : public ClientAsyncReaderInterface<R> {
   }
 
   void Read(R* msg, void* tag) override {
-    assert(started_);
+    GPR_CODEGEN_ASSERT(started_);
     read_ops_.set_output_tag(tag);
     if (!context_->initial_metadata_received_) {
       read_ops_.RecvInitialMetadata(context_);
@@ -247,8 +248,8 @@ class ClientAsyncReader final : public ClientAsyncReaderInterface<R> {
   /// Side effect:
   ///   - the \a ClientContext associated with this call is updated with
   ///     possible initial and trailing metadata received from the server.
-  void Finish(Status* status, void* tag) override {
-    assert(started_);
+  void Finish(::grpc::Status* status, void* tag) override {
+    GPR_CODEGEN_ASSERT(started_);
     finish_ops_.set_output_tag(tag);
     if (!context_->initial_metadata_received_) {
       finish_ops_.RecvInitialMetadata(context_);
@@ -260,7 +261,7 @@ class ClientAsyncReader final : public ClientAsyncReaderInterface<R> {
  private:
   friend class internal::ClientAsyncReaderFactory<R>;
   template <class W>
-  ClientAsyncReader(::grpc::internal::Call call, ClientContext* context,
+  ClientAsyncReader(::grpc::internal::Call call, ::grpc::ClientContext* context,
                     const W& request, bool start, void* tag)
       : context_(context), call_(call), started_(start) {
     // TODO(ctiller): don't assert
@@ -269,7 +270,7 @@ class ClientAsyncReader final : public ClientAsyncReaderInterface<R> {
     if (start) {
       StartCallInternal(tag);
     } else {
-      assert(tag == nullptr);
+      GPR_CODEGEN_ASSERT(tag == nullptr);
     }
   }
 
@@ -280,7 +281,7 @@ class ClientAsyncReader final : public ClientAsyncReaderInterface<R> {
     call_.PerformOps(&init_ops_);
   }
 
-  ClientContext* context_;
+  ::grpc::ClientContext* context_;
   ::grpc::internal::Call call_;
   bool started_;
   ::grpc::internal::CallOpSet<::grpc::internal::CallOpSendInitialMetadata,
@@ -326,13 +327,13 @@ class ClientAsyncWriterFactory {
   /// message from the server upon a successful call to the \a Finish
   /// method of this instance.
   template <class R>
-  static ClientAsyncWriter<W>* Create(ChannelInterface* channel,
-                                      CompletionQueue* cq,
+  static ClientAsyncWriter<W>* Create(::grpc::ChannelInterface* channel,
+                                      ::grpc::CompletionQueue* cq,
                                       const ::grpc::internal::RpcMethod& method,
-                                      ClientContext* context, R* response,
-                                      bool start, void* tag) {
+                                      ::grpc::ClientContext* context,
+                                      R* response, bool start, void* tag) {
     ::grpc::internal::Call call = channel->CreateCall(method, context, cq);
-    return new (g_core_codegen_interface->grpc_call_arena_alloc(
+    return new (::grpc::g_core_codegen_interface->grpc_call_arena_alloc(
         call.call(), sizeof(ClientAsyncWriter<W>)))
         ClientAsyncWriter<W>(call, context, response, start, tag);
   }
@@ -346,8 +347,8 @@ template <class W>
 class ClientAsyncWriter final : public ClientAsyncWriterInterface<W> {
  public:
   // always allocated against a call arena, no memory free required
-  static void operator delete(void* ptr, std::size_t size) {
-    assert(size == sizeof(ClientAsyncWriter));
+  static void operator delete(void* /*ptr*/, std::size_t size) {
+    GPR_CODEGEN_ASSERT(size == sizeof(ClientAsyncWriter));
   }
 
   // This operator should never be called as the memory should be freed as part
@@ -355,10 +356,10 @@ class ClientAsyncWriter final : public ClientAsyncWriterInterface<W> {
   // delete to the operator new so that some compilers will not complain (see
   // https://github.com/grpc/grpc/issues/11301) Note at the time of adding this
   // there are no tests catching the compiler warning.
-  static void operator delete(void*, void*) { assert(0); }
+  static void operator delete(void*, void*) { GPR_CODEGEN_ASSERT(false); }
 
   void StartCall(void* tag) override {
-    assert(!started_);
+    GPR_CODEGEN_ASSERT(!started_);
     started_ = true;
     StartCallInternal(tag);
   }
@@ -371,7 +372,7 @@ class ClientAsyncWriter final : public ClientAsyncWriterInterface<W> {
   ///     associated with this call is updated, and the calling code can access
   ///     the received metadata through the \a ClientContext.
   void ReadInitialMetadata(void* tag) override {
-    assert(started_);
+    GPR_CODEGEN_ASSERT(started_);
     GPR_CODEGEN_ASSERT(!context_->initial_metadata_received_);
 
     meta_ops_.set_output_tag(tag);
@@ -380,15 +381,15 @@ class ClientAsyncWriter final : public ClientAsyncWriterInterface<W> {
   }
 
   void Write(const W& msg, void* tag) override {
-    assert(started_);
+    GPR_CODEGEN_ASSERT(started_);
     write_ops_.set_output_tag(tag);
     // TODO(ctiller): don't assert
     GPR_CODEGEN_ASSERT(write_ops_.SendMessage(msg).ok());
     call_.PerformOps(&write_ops_);
   }
 
-  void Write(const W& msg, WriteOptions options, void* tag) override {
-    assert(started_);
+  void Write(const W& msg, ::grpc::WriteOptions options, void* tag) override {
+    GPR_CODEGEN_ASSERT(started_);
     write_ops_.set_output_tag(tag);
     if (options.is_last_message()) {
       options.set_buffer_hint();
@@ -400,7 +401,7 @@ class ClientAsyncWriter final : public ClientAsyncWriterInterface<W> {
   }
 
   void WritesDone(void* tag) override {
-    assert(started_);
+    GPR_CODEGEN_ASSERT(started_);
     write_ops_.set_output_tag(tag);
     write_ops_.ClientSendClose();
     call_.PerformOps(&write_ops_);
@@ -413,8 +414,8 @@ class ClientAsyncWriter final : public ClientAsyncWriterInterface<W> {
   ///     possible initial and trailing metadata received from the server.
   ///   - attempts to fill in the \a response parameter passed to this class's
   ///     constructor with the server's response message.
-  void Finish(Status* status, void* tag) override {
-    assert(started_);
+  void Finish(::grpc::Status* status, void* tag) override {
+    GPR_CODEGEN_ASSERT(started_);
     finish_ops_.set_output_tag(tag);
     if (!context_->initial_metadata_received_) {
       finish_ops_.RecvInitialMetadata(context_);
@@ -426,7 +427,7 @@ class ClientAsyncWriter final : public ClientAsyncWriterInterface<W> {
  private:
   friend class internal::ClientAsyncWriterFactory<W>;
   template <class R>
-  ClientAsyncWriter(::grpc::internal::Call call, ClientContext* context,
+  ClientAsyncWriter(::grpc::internal::Call call, ::grpc::ClientContext* context,
                     R* response, bool start, void* tag)
       : context_(context), call_(call), started_(start) {
     finish_ops_.RecvMessage(response);
@@ -434,7 +435,7 @@ class ClientAsyncWriter final : public ClientAsyncWriterInterface<W> {
     if (start) {
       StartCallInternal(tag);
     } else {
-      assert(tag == nullptr);
+      GPR_CODEGEN_ASSERT(tag == nullptr);
     }
   }
 
@@ -449,7 +450,7 @@ class ClientAsyncWriter final : public ClientAsyncWriterInterface<W> {
     }
   }
 
-  ClientContext* context_;
+  ::grpc::ClientContext* context_;
   ::grpc::internal::Call call_;
   bool started_;
   ::grpc::internal::CallOpSet<::grpc::internal::CallOpRecvInitialMetadata>
@@ -492,12 +493,12 @@ class ClientAsyncReaderWriterFactory {
   /// Note that \a context will be used to fill in custom initial metadata
   /// used to send to the server when starting the call.
   static ClientAsyncReaderWriter<W, R>* Create(
-      ChannelInterface* channel, CompletionQueue* cq,
-      const ::grpc::internal::RpcMethod& method, ClientContext* context,
+      ::grpc::ChannelInterface* channel, ::grpc::CompletionQueue* cq,
+      const ::grpc::internal::RpcMethod& method, ::grpc::ClientContext* context,
       bool start, void* tag) {
     ::grpc::internal::Call call = channel->CreateCall(method, context, cq);
 
-    return new (g_core_codegen_interface->grpc_call_arena_alloc(
+    return new (::grpc::g_core_codegen_interface->grpc_call_arena_alloc(
         call.call(), sizeof(ClientAsyncReaderWriter<W, R>)))
         ClientAsyncReaderWriter<W, R>(call, context, start, tag);
   }
@@ -513,8 +514,8 @@ class ClientAsyncReaderWriter final
     : public ClientAsyncReaderWriterInterface<W, R> {
  public:
   // always allocated against a call arena, no memory free required
-  static void operator delete(void* ptr, std::size_t size) {
-    assert(size == sizeof(ClientAsyncReaderWriter));
+  static void operator delete(void* /*ptr*/, std::size_t size) {
+    GPR_CODEGEN_ASSERT(size == sizeof(ClientAsyncReaderWriter));
   }
 
   // This operator should never be called as the memory should be freed as part
@@ -522,10 +523,10 @@ class ClientAsyncReaderWriter final
   // delete to the operator new so that some compilers will not complain (see
   // https://github.com/grpc/grpc/issues/11301) Note at the time of adding this
   // there are no tests catching the compiler warning.
-  static void operator delete(void*, void*) { assert(0); }
+  static void operator delete(void*, void*) { GPR_CODEGEN_ASSERT(false); }
 
   void StartCall(void* tag) override {
-    assert(!started_);
+    GPR_CODEGEN_ASSERT(!started_);
     started_ = true;
     StartCallInternal(tag);
   }
@@ -538,7 +539,7 @@ class ClientAsyncReaderWriter final
   ///     is updated with it, and then the receiving initial metadata can
   ///     be accessed through this \a ClientContext.
   void ReadInitialMetadata(void* tag) override {
-    assert(started_);
+    GPR_CODEGEN_ASSERT(started_);
     GPR_CODEGEN_ASSERT(!context_->initial_metadata_received_);
 
     meta_ops_.set_output_tag(tag);
@@ -547,7 +548,7 @@ class ClientAsyncReaderWriter final
   }
 
   void Read(R* msg, void* tag) override {
-    assert(started_);
+    GPR_CODEGEN_ASSERT(started_);
     read_ops_.set_output_tag(tag);
     if (!context_->initial_metadata_received_) {
       read_ops_.RecvInitialMetadata(context_);
@@ -557,15 +558,15 @@ class ClientAsyncReaderWriter final
   }
 
   void Write(const W& msg, void* tag) override {
-    assert(started_);
+    GPR_CODEGEN_ASSERT(started_);
     write_ops_.set_output_tag(tag);
     // TODO(ctiller): don't assert
     GPR_CODEGEN_ASSERT(write_ops_.SendMessage(msg).ok());
     call_.PerformOps(&write_ops_);
   }
 
-  void Write(const W& msg, WriteOptions options, void* tag) override {
-    assert(started_);
+  void Write(const W& msg, ::grpc::WriteOptions options, void* tag) override {
+    GPR_CODEGEN_ASSERT(started_);
     write_ops_.set_output_tag(tag);
     if (options.is_last_message()) {
       options.set_buffer_hint();
@@ -577,7 +578,7 @@ class ClientAsyncReaderWriter final
   }
 
   void WritesDone(void* tag) override {
-    assert(started_);
+    GPR_CODEGEN_ASSERT(started_);
     write_ops_.set_output_tag(tag);
     write_ops_.ClientSendClose();
     call_.PerformOps(&write_ops_);
@@ -587,8 +588,8 @@ class ClientAsyncReaderWriter final
   /// Side effect
   ///   - the \a ClientContext associated with this call is updated with
   ///     possible initial and trailing metadata sent from the server.
-  void Finish(Status* status, void* tag) override {
-    assert(started_);
+  void Finish(::grpc::Status* status, void* tag) override {
+    GPR_CODEGEN_ASSERT(started_);
     finish_ops_.set_output_tag(tag);
     if (!context_->initial_metadata_received_) {
       finish_ops_.RecvInitialMetadata(context_);
@@ -599,13 +600,13 @@ class ClientAsyncReaderWriter final
 
  private:
   friend class internal::ClientAsyncReaderWriterFactory<W, R>;
-  ClientAsyncReaderWriter(::grpc::internal::Call call, ClientContext* context,
-                          bool start, void* tag)
+  ClientAsyncReaderWriter(::grpc::internal::Call call,
+                          ::grpc::ClientContext* context, bool start, void* tag)
       : context_(context), call_(call), started_(start) {
     if (start) {
       StartCallInternal(tag);
     } else {
-      assert(tag == nullptr);
+      GPR_CODEGEN_ASSERT(tag == nullptr);
     }
   }
 
@@ -620,7 +621,7 @@ class ClientAsyncReaderWriter final
     }
   }
 
-  ClientContext* context_;
+  ::grpc::ClientContext* context_;
   ::grpc::internal::Call call_;
   bool started_;
   ::grpc::internal::CallOpSet<::grpc::internal::CallOpRecvInitialMetadata>
@@ -639,7 +640,7 @@ class ClientAsyncReaderWriter final
 
 template <class W, class R>
 class ServerAsyncReaderInterface
-    : public internal::ServerAsyncStreamingInterface,
+    : public ::grpc::internal::ServerAsyncStreamingInterface,
       public internal::AsyncReaderInterface<R> {
  public:
   /// Indicate that the stream is to be finished with a certain status code
@@ -664,7 +665,8 @@ class ServerAsyncReaderInterface
   /// \param[in] tag Tag identifying this request.
   /// \param[in] status To be sent to the client as the result of this call.
   /// \param[in] msg To be sent to the client as the response for this call.
-  virtual void Finish(const W& msg, const Status& status, void* tag) = 0;
+  virtual void Finish(const W& msg, const ::grpc::Status& status,
+                      void* tag) = 0;
 
   /// Indicate that the stream is to be finished with a certain
   /// non-OK status code.
@@ -687,7 +689,7 @@ class ServerAsyncReaderInterface
   /// \param[in] tag Tag identifying this request.
   /// \param[in] status To be sent to the client as the result of this call.
   ///     - Note: \a status must have a non-OK code.
-  virtual void FinishWithError(const Status& status, void* tag) = 0;
+  virtual void FinishWithError(const ::grpc::Status& status, void* tag) = 0;
 };
 
 /// Async server-side API for doing client-streaming RPCs,
@@ -696,7 +698,7 @@ class ServerAsyncReaderInterface
 template <class W, class R>
 class ServerAsyncReader final : public ServerAsyncReaderInterface<W, R> {
  public:
-  explicit ServerAsyncReader(ServerContext* ctx)
+  explicit ServerAsyncReader(::grpc::ServerContext* ctx)
       : call_(nullptr, nullptr, nullptr), ctx_(ctx) {}
 
   /// See \a ServerAsyncStreamingInterface::SendInitialMetadata for semantics.
@@ -734,7 +736,7 @@ class ServerAsyncReader final : public ServerAsyncReaderInterface<W, R> {
   ///
   /// gRPC doesn't take ownership or a reference to \a msg and \a status, so it
   /// is safe to deallocate once Finish returns.
-  void Finish(const W& msg, const Status& status, void* tag) override {
+  void Finish(const W& msg, const ::grpc::Status& status, void* tag) override {
     finish_ops_.set_output_tag(tag);
     if (!ctx_->sent_initial_metadata_) {
       finish_ops_.SendInitialMetadata(&ctx_->initial_metadata_,
@@ -763,7 +765,7 @@ class ServerAsyncReader final : public ServerAsyncReaderInterface<W, R> {
   ///
   /// gRPC doesn't take ownership or a reference to \a status, so it is safe to
   /// to deallocate once FinishWithError returns.
-  void FinishWithError(const Status& status, void* tag) override {
+  void FinishWithError(const ::grpc::Status& status, void* tag) override {
     GPR_CODEGEN_ASSERT(!status.ok());
     finish_ops_.set_output_tag(tag);
     if (!ctx_->sent_initial_metadata_) {
@@ -782,7 +784,7 @@ class ServerAsyncReader final : public ServerAsyncReaderInterface<W, R> {
   void BindCall(::grpc::internal::Call* call) override { call_ = *call; }
 
   ::grpc::internal::Call call_;
-  ServerContext* ctx_;
+  ::grpc::ServerContext* ctx_;
   ::grpc::internal::CallOpSet<::grpc::internal::CallOpSendInitialMetadata>
       meta_ops_;
   ::grpc::internal::CallOpSet<::grpc::internal::CallOpRecvMessage<R>> read_ops_;
@@ -794,7 +796,7 @@ class ServerAsyncReader final : public ServerAsyncReaderInterface<W, R> {
 
 template <class W>
 class ServerAsyncWriterInterface
-    : public internal::ServerAsyncStreamingInterface,
+    : public ::grpc::internal::ServerAsyncStreamingInterface,
       public internal::AsyncWriterInterface<W> {
  public:
   /// Indicate that the stream is to be finished with a certain status code.
@@ -818,7 +820,7 @@ class ServerAsyncWriterInterface
   ///
   /// \param[in] tag Tag identifying this request.
   /// \param[in] status To be sent to the client as the result of this call.
-  virtual void Finish(const Status& status, void* tag) = 0;
+  virtual void Finish(const ::grpc::Status& status, void* tag) = 0;
 
   /// Request the writing of \a msg and coalesce it with trailing metadata which
   /// contains \a status, using WriteOptions options with
@@ -834,8 +836,8 @@ class ServerAsyncWriterInterface
   /// \param[in] options The WriteOptions to be used to write this message.
   /// \param[in] status The Status that server returns to client.
   /// \param[in] tag The tag identifying the operation.
-  virtual void WriteAndFinish(const W& msg, WriteOptions options,
-                              const Status& status, void* tag) = 0;
+  virtual void WriteAndFinish(const W& msg, ::grpc::WriteOptions options,
+                              const ::grpc::Status& status, void* tag) = 0;
 };
 
 /// Async server-side API for doing server streaming RPCs,
@@ -843,7 +845,7 @@ class ServerAsyncWriterInterface
 template <class W>
 class ServerAsyncWriter final : public ServerAsyncWriterInterface<W> {
  public:
-  explicit ServerAsyncWriter(ServerContext* ctx)
+  explicit ServerAsyncWriter(::grpc::ServerContext* ctx)
       : call_(nullptr, nullptr, nullptr), ctx_(ctx) {}
 
   /// See \a ServerAsyncStreamingInterface::SendInitialMetadata for semantics.
@@ -874,7 +876,7 @@ class ServerAsyncWriter final : public ServerAsyncWriterInterface<W> {
     call_.PerformOps(&write_ops_);
   }
 
-  void Write(const W& msg, WriteOptions options, void* tag) override {
+  void Write(const W& msg, ::grpc::WriteOptions options, void* tag) override {
     write_ops_.set_output_tag(tag);
     if (options.is_last_message()) {
       options.set_buffer_hint();
@@ -896,8 +898,8 @@ class ServerAsyncWriter final : public ServerAsyncWriterInterface<W> {
   ///
   /// gRPC doesn't take ownership or a reference to \a msg and \a status, so it
   /// is safe to deallocate once WriteAndFinish returns.
-  void WriteAndFinish(const W& msg, WriteOptions options, const Status& status,
-                      void* tag) override {
+  void WriteAndFinish(const W& msg, ::grpc::WriteOptions options,
+                      const ::grpc::Status& status, void* tag) override {
     write_ops_.set_output_tag(tag);
     EnsureInitialMetadataSent(&write_ops_);
     options.set_buffer_hint();
@@ -917,7 +919,7 @@ class ServerAsyncWriter final : public ServerAsyncWriterInterface<W> {
   ///
   /// gRPC doesn't take ownership or a reference to \a status, so it is safe to
   /// to deallocate once Finish returns.
-  void Finish(const Status& status, void* tag) override {
+  void Finish(const ::grpc::Status& status, void* tag) override {
     finish_ops_.set_output_tag(tag);
     EnsureInitialMetadataSent(&finish_ops_);
     finish_ops_.ServerSendStatus(&ctx_->trailing_metadata_, status);
@@ -940,7 +942,7 @@ class ServerAsyncWriter final : public ServerAsyncWriterInterface<W> {
   }
 
   ::grpc::internal::Call call_;
-  ServerContext* ctx_;
+  ::grpc::ServerContext* ctx_;
   ::grpc::internal::CallOpSet<::grpc::internal::CallOpSendInitialMetadata>
       meta_ops_;
   ::grpc::internal::CallOpSet<::grpc::internal::CallOpSendInitialMetadata,
@@ -955,7 +957,7 @@ class ServerAsyncWriter final : public ServerAsyncWriterInterface<W> {
 /// Server-side interface for asynchronous bi-directional streaming.
 template <class W, class R>
 class ServerAsyncReaderWriterInterface
-    : public internal::ServerAsyncStreamingInterface,
+    : public ::grpc::internal::ServerAsyncStreamingInterface,
       public internal::AsyncWriterInterface<W>,
       public internal::AsyncReaderInterface<R> {
  public:
@@ -981,7 +983,7 @@ class ServerAsyncReaderWriterInterface
   ///
   /// \param[in] tag Tag identifying this request.
   /// \param[in] status To be sent to the client as the result of this call.
-  virtual void Finish(const Status& status, void* tag) = 0;
+  virtual void Finish(const ::grpc::Status& status, void* tag) = 0;
 
   /// Request the writing of \a msg and coalesce it with trailing metadata which
   /// contains \a status, using WriteOptions options with
@@ -997,8 +999,8 @@ class ServerAsyncReaderWriterInterface
   /// \param[in] options The WriteOptions to be used to write this message.
   /// \param[in] status The Status that server returns to client.
   /// \param[in] tag The tag identifying the operation.
-  virtual void WriteAndFinish(const W& msg, WriteOptions options,
-                              const Status& status, void* tag) = 0;
+  virtual void WriteAndFinish(const W& msg, ::grpc::WriteOptions options,
+                              const ::grpc::Status& status, void* tag) = 0;
 };
 
 /// Async server-side API for doing bidirectional streaming RPCs,
@@ -1009,7 +1011,7 @@ template <class W, class R>
 class ServerAsyncReaderWriter final
     : public ServerAsyncReaderWriterInterface<W, R> {
  public:
-  explicit ServerAsyncReaderWriter(ServerContext* ctx)
+  explicit ServerAsyncReaderWriter(::grpc::ServerContext* ctx)
       : call_(nullptr, nullptr, nullptr), ctx_(ctx) {}
 
   /// See \a ServerAsyncStreamingInterface::SendInitialMetadata for semantics.
@@ -1046,7 +1048,7 @@ class ServerAsyncReaderWriter final
     call_.PerformOps(&write_ops_);
   }
 
-  void Write(const W& msg, WriteOptions options, void* tag) override {
+  void Write(const W& msg, ::grpc::WriteOptions options, void* tag) override {
     write_ops_.set_output_tag(tag);
     if (options.is_last_message()) {
       options.set_buffer_hint();
@@ -1067,8 +1069,8 @@ class ServerAsyncReaderWriter final
   //
   /// gRPC doesn't take ownership or a reference to \a msg and \a status, so it
   /// is safe to deallocate once WriteAndFinish returns.
-  void WriteAndFinish(const W& msg, WriteOptions options, const Status& status,
-                      void* tag) override {
+  void WriteAndFinish(const W& msg, ::grpc::WriteOptions options,
+                      const ::grpc::Status& status, void* tag) override {
     write_ops_.set_output_tag(tag);
     EnsureInitialMetadataSent(&write_ops_);
     options.set_buffer_hint();
@@ -1088,7 +1090,7 @@ class ServerAsyncReaderWriter final
   //
   /// gRPC doesn't take ownership or a reference to \a status, so it is safe to
   /// to deallocate once Finish returns.
-  void Finish(const Status& status, void* tag) override {
+  void Finish(const ::grpc::Status& status, void* tag) override {
     finish_ops_.set_output_tag(tag);
     EnsureInitialMetadataSent(&finish_ops_);
 
@@ -1097,7 +1099,7 @@ class ServerAsyncReaderWriter final
   }
 
  private:
-  friend class ::grpc_impl::Server;
+  friend class ::grpc::Server;
 
   void BindCall(::grpc::internal::Call* call) override { call_ = *call; }
 
@@ -1114,7 +1116,7 @@ class ServerAsyncReaderWriter final
   }
 
   ::grpc::internal::Call call_;
-  ServerContext* ctx_;
+  ::grpc::ServerContext* ctx_;
   ::grpc::internal::CallOpSet<::grpc::internal::CallOpSendInitialMetadata>
       meta_ops_;
   ::grpc::internal::CallOpSet<::grpc::internal::CallOpRecvMessage<R>> read_ops_;
@@ -1128,5 +1130,4 @@ class ServerAsyncReaderWriter final
 };
 
 }  // namespace grpc
-
 #endif  // GRPCPP_IMPL_CODEGEN_ASYNC_STREAM_H