From 5dfeec7a7e6882a08a6965a7925d7ba6a44172d9 Mon Sep 17 00:00:00 2001 From: AJ Heller <hork@google.com> Date: Wed, 26 Jan 2022 20:43:44 -0800 Subject: [PATCH] Update docs for ServerAsyncResponseWriter::Finish object lifetimes (#28290) Fixes #28239 --- include/grpcpp/impl/codegen/async_unary_call.h | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/include/grpcpp/impl/codegen/async_unary_call.h b/include/grpcpp/impl/codegen/async_unary_call.h index d7a3b57314a..7928e316a3e 100644 --- a/include/grpcpp/impl/codegen/async_unary_call.h +++ b/include/grpcpp/impl/codegen/async_unary_call.h @@ -334,6 +334,10 @@ class ServerAsyncResponseWriter final /// Note: if \a status has a non-OK code, then \a msg will not be sent, /// and the client will receive only the status with possible trailing /// metadata. + /// + /// gRPC doesn't take ownership or a reference to msg and status, so it is + /// safe to deallocate them once the Finish operation is complete (i.e. a + /// result arrives in the completion queue). void Finish(const W& msg, const ::grpc::Status& status, void* tag) { finish_buf_.set_output_tag(tag); finish_buf_.set_core_cq_tag(&finish_buf_); @@ -367,6 +371,10 @@ class ServerAsyncResponseWriter final /// Side effect: /// - also sends initial metadata if not already sent (using the /// \a ServerContext associated with this call). + /// + /// gRPC doesn't take ownership or a reference to status, so it is safe to + /// deallocate them once the Finish operation is complete (i.e. a result + /// arrives in the completion queue). void FinishWithError(const ::grpc::Status& status, void* tag) { GPR_CODEGEN_ASSERT(!status.ok()); finish_buf_.set_output_tag(tag);