diff options
Diffstat (limited to 'include/grpc++/channel.h')
-rw-r--r-- | include/grpc++/channel.h | 81 |
1 files changed, 15 insertions, 66 deletions
diff --git a/include/grpc++/channel.h b/include/grpc++/channel.h index 541be1345f..80547f7ab8 100644 --- a/include/grpc++/channel.h +++ b/include/grpc++/channel.h @@ -36,99 +36,48 @@ #include <memory> -#include <grpc/grpc.h> #include <grpc++/impl/call.h> -#include <grpc++/impl/grpc_library.h> -#include <grpc++/support/config.h> +#include <grpc++/impl/codegen/channel_interface.h> +#include <grpc++/impl/codegen/config.h> +#include <grpc++/impl/codegen/grpc_library.h> +#include <grpc/grpc.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 CallHook, - public std::enable_shared_from_this<Channel> { + public std::enable_shared_from_this<Channel>, + private GrpcLibrary { public: ~Channel(); /// 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) GRPC_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) GRPC_OVERRIDE; + void PerformOpsOnCall(CallOpSetInterface* ops, Call* call) GRPC_OVERRIDE; + void* RegisterMethod(const char* method) GRPC_OVERRIDE; void NotifyOnStateChangeImpl(grpc_connectivity_state last_observed, gpr_timespec deadline, CompletionQueue* cq, - void* tag); + void* tag) GRPC_OVERRIDE; bool WaitForStateChangeImpl(grpc_connectivity_state last_observed, - gpr_timespec deadline); + gpr_timespec deadline) GRPC_OVERRIDE; const grpc::string host_; grpc_channel* const c_channel_; // owned |