Skip to content
Snippets Groups Projects
Commit b4a265ae authored by Yang Gao's avatar Yang Gao Committed by GitHub
Browse files

Merge pull request #11723 from yang-g/cpp_is_hard

Use pointer to avoid assignment and race.
parents 05f6d7e5 a3d92916
No related branches found
No related tags found
No related merge requests found
...@@ -123,18 +123,18 @@ class ClientAsyncResponseReader final ...@@ -123,18 +123,18 @@ class ClientAsyncResponseReader final
void ReadInitialMetadata(void* tag) { void ReadInitialMetadata(void* tag) {
GPR_CODEGEN_ASSERT(!context_->initial_metadata_received_); GPR_CODEGEN_ASSERT(!context_->initial_metadata_received_);
Ops& o = ops_; Ops* o = &ops_;
// TODO(vjpai): Remove the collection_ specialization as soon // TODO(vjpai): Remove the collection_ specialization as soon
// as the public constructor is deleted // as the public constructor is deleted
if (collection_) { if (collection_) {
o = *collection_; o = collection_.get();
collection_->meta_buf.SetCollection(collection_); collection_->meta_buf.SetCollection(collection_);
} }
o.meta_buf.set_output_tag(tag); o->meta_buf.set_output_tag(tag);
o.meta_buf.RecvInitialMetadata(context_); o->meta_buf.RecvInitialMetadata(context_);
call_.PerformOps(&o.meta_buf); call_.PerformOps(&o->meta_buf);
} }
/// See \a ClientAysncResponseReaderInterface::Finish for semantics. /// See \a ClientAysncResponseReaderInterface::Finish for semantics.
...@@ -143,23 +143,23 @@ class ClientAsyncResponseReader final ...@@ -143,23 +143,23 @@ class ClientAsyncResponseReader final
/// - the \a ClientContext associated with this call is updated with /// - the \a ClientContext associated with this call is updated with
/// possible initial and trailing metadata sent from the server. /// possible initial and trailing metadata sent from the server.
void Finish(R* msg, Status* status, void* tag) { void Finish(R* msg, Status* status, void* tag) {
Ops& o = ops_; Ops* o = &ops_;
// TODO(vjpai): Remove the collection_ specialization as soon // TODO(vjpai): Remove the collection_ specialization as soon
// as the public constructor is deleted // as the public constructor is deleted
if (collection_) { if (collection_) {
o = *collection_; o = collection_.get();
collection_->finish_buf.SetCollection(collection_); collection_->finish_buf.SetCollection(collection_);
} }
o.finish_buf.set_output_tag(tag); o->finish_buf.set_output_tag(tag);
if (!context_->initial_metadata_received_) { if (!context_->initial_metadata_received_) {
o.finish_buf.RecvInitialMetadata(context_); o->finish_buf.RecvInitialMetadata(context_);
} }
o.finish_buf.RecvMessage(msg); o->finish_buf.RecvMessage(msg);
o.finish_buf.AllowNoMessage(); o->finish_buf.AllowNoMessage();
o.finish_buf.ClientRecvStatus(context_, status); o->finish_buf.ClientRecvStatus(context_, status);
call_.PerformOps(&o.finish_buf); call_.PerformOps(&o->finish_buf);
} }
private: private:
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment