diff options
author | David Garcia Quintas <dgq@google.com> | 2016-01-13 16:02:00 -0800 |
---|---|---|
committer | David Garcia Quintas <dgq@google.com> | 2016-01-13 16:02:00 -0800 |
commit | e50c6c2f5ed36d8559de5c23364f7e0d656daab8 (patch) | |
tree | e40d0ea895f2b158f03d4bd6d4dbf189546738fd /include/grpc++/channel.h | |
parent | 16a7dee6141785092ee2aae4a11d2e9f590a1847 (diff) |
WIP. Added ChannelInterface
Diffstat (limited to 'include/grpc++/channel.h')
-rw-r--r-- | include/grpc++/channel.h | 72 |
1 files changed, 10 insertions, 62 deletions
diff --git a/include/grpc++/channel.h b/include/grpc++/channel.h index 541be1345f..7b54751ae3 100644 --- a/include/grpc++/channel.h +++ b/include/grpc++/channel.h @@ -38,35 +38,16 @@ #include <grpc/grpc.h> #include <grpc++/impl/call.h> +#include <grpc++/impl/codegen/channel_interface.h> #include <grpc++/impl/grpc_library.h> #include <grpc++/support/config.h> struct grpc_channel; namespace grpc { -class CallOpSetInterface; -class ChannelArguments; -class CompletionQueue; -class ChannelCredentials; -class SecureChannelCredentials; - -template <class R> -class ClientReader; -template <class W> -class ClientWriter; -template <class W, class R> -class ClientReaderWriter; -template <class R> -class ClientAsyncReader; -template <class W> -class ClientAsyncWriter; -template <class W, class R> -class ClientAsyncReaderWriter; -template <class R> -class ClientAsyncResponseReader; - /// Channels represent a connection to an endpoint. Created by \a CreateChannel. -class Channel GRPC_FINAL : public GrpcLibrary, +class Channel GRPC_FINAL : public ChannelInterface, + public GrpcLibrary, public CallHook, public std::enable_shared_from_this<Channel> { public: @@ -74,61 +55,28 @@ class Channel GRPC_FINAL : public GrpcLibrary, /// Get the current channel state. If the channel is in IDLE and /// \a try_to_connect is set to true, try to connect. - grpc_connectivity_state GetState(bool try_to_connect); - - /// Return the \a tag on \a cq when the channel state is changed or \a - /// deadline expires. \a GetState needs to called to get the current state. - template <typename T> - void NotifyOnStateChange(grpc_connectivity_state last_observed, T deadline, - CompletionQueue* cq, void* tag) { - TimePoint<T> deadline_tp(deadline); - NotifyOnStateChangeImpl(last_observed, deadline_tp.raw_time(), cq, tag); - } - - /// Blocking wait for channel state change or \a deadline expiration. - /// \a GetState needs to called to get the current state. - template <typename T> - bool WaitForStateChange(grpc_connectivity_state last_observed, T deadline) { - TimePoint<T> deadline_tp(deadline); - return WaitForStateChangeImpl(last_observed, deadline_tp.raw_time()); - } + grpc_connectivity_state GetState(bool try_to_connect) override; private: - template <class R> - friend class ::grpc::ClientReader; - template <class W> - friend class ::grpc::ClientWriter; - template <class W, class R> - friend class ::grpc::ClientReaderWriter; - template <class R> - friend class ::grpc::ClientAsyncReader; - template <class W> - friend class ::grpc::ClientAsyncWriter; - template <class W, class R> - friend class ::grpc::ClientAsyncReaderWriter; - template <class R> - friend class ::grpc::ClientAsyncResponseReader; template <class InputMessage, class OutputMessage> - friend Status BlockingUnaryCall(Channel* channel, const RpcMethod& method, + friend Status BlockingUnaryCall(ChannelInterface* channel, const RpcMethod& method, ClientContext* context, const InputMessage& request, OutputMessage* result); - friend class ::grpc::RpcMethod; friend std::shared_ptr<Channel> CreateChannelInternal( const grpc::string& host, grpc_channel* c_channel); - Channel(const grpc::string& host, grpc_channel* c_channel); Call CreateCall(const RpcMethod& method, ClientContext* context, - CompletionQueue* cq); - void PerformOpsOnCall(CallOpSetInterface* ops, Call* call); - void* RegisterMethod(const char* method); + CompletionQueue* cq) override; + void PerformOpsOnCall(CallOpSetInterface* ops, Call* call) override; + void* RegisterMethod(const char* method) override; void NotifyOnStateChangeImpl(grpc_connectivity_state last_observed, gpr_timespec deadline, CompletionQueue* cq, - void* tag); + void* tag) override; bool WaitForStateChangeImpl(grpc_connectivity_state last_observed, - gpr_timespec deadline); + gpr_timespec deadline) override; const grpc::string host_; grpc_channel* const c_channel_; // owned |