diff options
author | kpayson64 <kpayson@google.com> | 2016-08-30 08:34:19 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2016-08-30 08:34:19 -0700 |
commit | d76ea8372809be7928b9b165685ae474b581a1cf (patch) | |
tree | 8a785919a406015e613f04d652ecab789a712b99 /include | |
parent | bacaceb543d6c9d8208177962fd286dffe75ef72 (diff) | |
parent | 59e835d43189722e9e84db12ea067001c521c98d (diff) |
Merge pull request #7798 from y-zeng/ServerReaderWriterInterface
Add ServerReaderWriterInterface
Diffstat (limited to 'include')
-rw-r--r-- | include/grpc++/impl/codegen/sync_stream.h | 37 |
1 files changed, 30 insertions, 7 deletions
diff --git a/include/grpc++/impl/codegen/sync_stream.h b/include/grpc++/impl/codegen/sync_stream.h index b2b972760d..7601ceae92 100644 --- a/include/grpc++/impl/codegen/sync_stream.h +++ b/include/grpc++/impl/codegen/sync_stream.h @@ -64,6 +64,15 @@ class ClientStreamingInterface { virtual Status Finish() = 0; }; +/// Common interface for all synchronous server side streaming. +class ServerStreamingInterface { + public: + virtual ~ServerStreamingInterface() {} + + /// Blocking send initial metadata to client. + virtual void SendInitialMetadata() = 0; +}; + /// An interface that yields a sequence of messages of type \a R. template <class R> class ReaderInterface { @@ -336,12 +345,17 @@ class ClientReaderWriter GRPC_FINAL : public ClientReaderWriterInterface<W, R> { Call call_; }; +/// Server-side interface for streaming reads of message of type \a R. +template <class R> +class ServerReaderInterface : public ServerStreamingInterface, + public ReaderInterface<R> {}; + template <class R> -class ServerReader GRPC_FINAL : public ReaderInterface<R> { +class ServerReader GRPC_FINAL : public ServerReaderInterface<R> { public: ServerReader(Call* call, ServerContext* ctx) : call_(call), ctx_(ctx) {} - void SendInitialMetadata() { + void SendInitialMetadata() GRPC_OVERRIDE { GPR_CODEGEN_ASSERT(!ctx_->sent_initial_metadata_); CallOpSet<CallOpSendInitialMetadata> ops; @@ -367,12 +381,17 @@ class ServerReader GRPC_FINAL : public ReaderInterface<R> { ServerContext* const ctx_; }; +/// Server-side interface for streaming writes of message of type \a W. template <class W> -class ServerWriter GRPC_FINAL : public WriterInterface<W> { +class ServerWriterInterface : public ServerStreamingInterface, + public WriterInterface<W> {}; + +template <class W> +class ServerWriter GRPC_FINAL : public ServerWriterInterface<W> { public: ServerWriter(Call* call, ServerContext* ctx) : call_(call), ctx_(ctx) {} - void SendInitialMetadata() { + void SendInitialMetadata() GRPC_OVERRIDE { GPR_CODEGEN_ASSERT(!ctx_->sent_initial_metadata_); CallOpSet<CallOpSendInitialMetadata> ops; @@ -411,12 +430,16 @@ class ServerWriter GRPC_FINAL : public WriterInterface<W> { /// Server-side interface for bi-directional streaming. template <class W, class R> -class ServerReaderWriter GRPC_FINAL : public WriterInterface<W>, - public ReaderInterface<R> { +class ServerReaderWriterInterface : public ServerStreamingInterface, + public WriterInterface<W>, + public ReaderInterface<R> {}; + +template <class W, class R> +class ServerReaderWriter GRPC_FINAL : public ServerReaderWriterInterface<W, R> { public: ServerReaderWriter(Call* call, ServerContext* ctx) : call_(call), ctx_(ctx) {} - void SendInitialMetadata() { + void SendInitialMetadata() GRPC_OVERRIDE { GPR_CODEGEN_ASSERT(!ctx_->sent_initial_metadata_); CallOpSet<CallOpSendInitialMetadata> ops; |