diff options
author | 2016-02-12 14:54:16 -0800 | |
---|---|---|
committer | 2016-02-12 14:54:16 -0800 | |
commit | a3c968d9c263b7e380f524bcb27195a76ff3d4b7 (patch) | |
tree | 23907ff5633e431a4497d8ddffe035941bba263c /include/grpc++ | |
parent | 1945ae42854689afa398e46d3086e55706fee655 (diff) | |
parent | 017f84ead8fe1709ecd9a9f7f532464d2a170ff9 (diff) |
Merge remote-tracking branch 'upstream/master' into inherit_from_grpc_library
Diffstat (limited to 'include/grpc++')
-rw-r--r-- | include/grpc++/alarm.h | 16 | ||||
-rw-r--r-- | include/grpc++/impl/codegen/server_interface.h | 2 | ||||
-rw-r--r-- | include/grpc++/impl/codegen/sync_stream.h | 20 |
3 files changed, 34 insertions, 4 deletions
diff --git a/include/grpc++/alarm.h b/include/grpc++/alarm.h index e2618195f0..9979c34e4f 100644 --- a/include/grpc++/alarm.h +++ b/include/grpc++/alarm.h @@ -36,9 +36,12 @@ #ifndef GRPCXX_ALARM_H #define GRPCXX_ALARM_H +#include <grpc++/impl/codegen/completion_queue_tag.h> #include <grpc++/impl/codegen/grpc_library.h> #include <grpc++/impl/codegen/time.h> +struct grpc_alarm; + namespace grpc { class CompletionQueue; @@ -61,6 +64,19 @@ class Alarm : private GrpcLibrary { void Cancel(); private: + class AlarmEntry : public CompletionQueueTag { + public: + AlarmEntry(void* tag) : tag_(tag) {} + bool FinalizeResult(void** tag, bool* status) GRPC_OVERRIDE { + *tag = tag_; + return true; + } + + private: + void* tag_; + }; + + AlarmEntry tag_; grpc_alarm* const alarm_; // owned }; diff --git a/include/grpc++/impl/codegen/server_interface.h b/include/grpc++/impl/codegen/server_interface.h index 5c187c93ed..f934619c20 100644 --- a/include/grpc++/impl/codegen/server_interface.h +++ b/include/grpc++/impl/codegen/server_interface.h @@ -42,7 +42,6 @@ namespace grpc { class AsyncGenericService; -class AsynchronousService; class GenericServerContext; class RpcService; class ServerAsyncStreamingInterface; @@ -79,7 +78,6 @@ class ServerInterface : public CallHook { virtual void Wait() = 0; protected: - friend class AsynchronousService; friend class Service; /// Register a service. This call does not take ownership of the service. diff --git a/include/grpc++/impl/codegen/sync_stream.h b/include/grpc++/impl/codegen/sync_stream.h index 33d25e837c..9ae48bd23d 100644 --- a/include/grpc++/impl/codegen/sync_stream.h +++ b/include/grpc++/impl/codegen/sync_stream.h @@ -193,6 +193,15 @@ class ClientWriter : public ClientWriterInterface<W> { cq_.Pluck(&ops); } + void WaitForInitialMetadata() { + GPR_ASSERT(!context_->initial_metadata_received_); + + CallOpSet<CallOpRecvInitialMetadata> ops; + ops.RecvInitialMetadata(context_); + call_.PerformOps(&ops); + cq_.Pluck(&ops); // status ignored + } + using WriterInterface<W>::Write; bool Write(const W& msg, const WriteOptions& options) GRPC_OVERRIDE { CallOpSet<CallOpSendMessage> ops; @@ -213,6 +222,9 @@ class ClientWriter : public ClientWriterInterface<W> { /// Read the final response and wait for the final status. Status Finish() GRPC_OVERRIDE { Status status; + if (!context_->initial_metadata_received_) { + finish_ops_.RecvInitialMetadata(context_); + } finish_ops_.ClientRecvStatus(context_, &status); call_.PerformOps(&finish_ops_); GPR_ASSERT(cq_.Pluck(&finish_ops_)); @@ -221,7 +233,8 @@ class ClientWriter : public ClientWriterInterface<W> { private: ClientContext* context_; - CallOpSet<CallOpGenericRecvMessage, CallOpClientRecvStatus> finish_ops_; + CallOpSet<CallOpRecvInitialMetadata, CallOpGenericRecvMessage, + CallOpClientRecvStatus> finish_ops_; CompletionQueue cq_; Call call_; }; @@ -292,7 +305,10 @@ class ClientReaderWriter GRPC_FINAL : public ClientReaderWriterInterface<W, R> { } Status Finish() GRPC_OVERRIDE { - CallOpSet<CallOpClientRecvStatus> ops; + CallOpSet<CallOpRecvInitialMetadata, CallOpClientRecvStatus> ops; + if (!context_->initial_metadata_received_) { + ops.RecvInitialMetadata(context_); + } Status status; ops.ClientRecvStatus(context_, &status); call_.PerformOps(&ops); |