|
|
|
@ -62,40 +62,50 @@ class ClientAsyncResponseReader GRPC_FINAL |
|
|
|
|
ClientAsyncResponseReader(ChannelInterface* channel, CompletionQueue* cq, |
|
|
|
|
const RpcMethod& method, ClientContext* context, |
|
|
|
|
const W& request) |
|
|
|
|
: context_(context), call_(channel->CreateCall(method, context, cq)) { |
|
|
|
|
init_buf_.SendInitialMetadata(context->send_initial_metadata_); |
|
|
|
|
: context_(context), |
|
|
|
|
call_(channel->CreateCall(method, context, cq)), |
|
|
|
|
collection_(new CallOpSetCollection) { |
|
|
|
|
collection_->init_buf_.SetCollection(collection_); |
|
|
|
|
collection_->init_buf_.SendInitialMetadata(context->send_initial_metadata_); |
|
|
|
|
// TODO(ctiller): don't assert
|
|
|
|
|
GPR_ASSERT(init_buf_.SendMessage(request).ok()); |
|
|
|
|
init_buf_.ClientSendClose(); |
|
|
|
|
call_.PerformOps(&init_buf_); |
|
|
|
|
GPR_ASSERT(collection_->init_buf_.SendMessage(request).ok()); |
|
|
|
|
collection_->init_buf_.ClientSendClose(); |
|
|
|
|
call_.PerformOps(&collection_->init_buf_); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
void ReadInitialMetadata(void* tag) { |
|
|
|
|
GPR_ASSERT(!context_->initial_metadata_received_); |
|
|
|
|
|
|
|
|
|
meta_buf_.set_output_tag(tag); |
|
|
|
|
meta_buf_.RecvInitialMetadata(context_); |
|
|
|
|
call_.PerformOps(&meta_buf_); |
|
|
|
|
collection_->meta_buf_.SetCollection(collection_); |
|
|
|
|
collection_->meta_buf_.set_output_tag(tag); |
|
|
|
|
collection_->meta_buf_.RecvInitialMetadata(context_); |
|
|
|
|
call_.PerformOps(&collection_->meta_buf_); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
void Finish(R* msg, Status* status, void* tag) { |
|
|
|
|
finish_buf_.set_output_tag(tag); |
|
|
|
|
collection_->finish_buf_.SetCollection(collection_); |
|
|
|
|
collection_->finish_buf_.set_output_tag(tag); |
|
|
|
|
if (!context_->initial_metadata_received_) { |
|
|
|
|
finish_buf_.RecvInitialMetadata(context_); |
|
|
|
|
collection_->finish_buf_.RecvInitialMetadata(context_); |
|
|
|
|
} |
|
|
|
|
finish_buf_.RecvMessage(msg); |
|
|
|
|
finish_buf_.ClientRecvStatus(context_, status); |
|
|
|
|
call_.PerformOps(&finish_buf_); |
|
|
|
|
collection_->finish_buf_.RecvMessage(msg); |
|
|
|
|
collection_->finish_buf_.ClientRecvStatus(context_, status); |
|
|
|
|
call_.PerformOps(&collection_->finish_buf_); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
private: |
|
|
|
|
ClientContext* context_; |
|
|
|
|
Call call_; |
|
|
|
|
SneakyCallOpSet<CallOpSendInitialMetadata, CallOpSendMessage, |
|
|
|
|
CallOpClientSendClose> init_buf_; |
|
|
|
|
CallOpSet<CallOpRecvInitialMetadata> meta_buf_; |
|
|
|
|
CallOpSet<CallOpRecvInitialMetadata, CallOpRecvMessage<R>, |
|
|
|
|
CallOpClientRecvStatus> finish_buf_; |
|
|
|
|
|
|
|
|
|
class CallOpSetCollection : public CallOpSetCollectionInterface { |
|
|
|
|
public: |
|
|
|
|
SneakyCallOpSet<CallOpSendInitialMetadata, CallOpSendMessage, |
|
|
|
|
CallOpClientSendClose> init_buf_; |
|
|
|
|
CallOpSet<CallOpRecvInitialMetadata> meta_buf_; |
|
|
|
|
CallOpSet<CallOpRecvInitialMetadata, CallOpRecvMessage<R>, |
|
|
|
|
CallOpClientRecvStatus> finish_buf_; |
|
|
|
|
}; |
|
|
|
|
std::shared_ptr<CallOpSetCollection> collection_; |
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
template <class W> |
|
|
|
|