diff options
Diffstat (limited to 'include/grpc++/impl')
-rw-r--r-- | include/grpc++/impl/README.md | 4 | ||||
-rw-r--r-- | include/grpc++/impl/call.h | 42 | ||||
-rw-r--r-- | include/grpc++/impl/client_unary_call.h | 9 | ||||
-rw-r--r-- | include/grpc++/impl/grpc_library.h | 1 | ||||
-rw-r--r-- | include/grpc++/impl/internal_stub.h | 57 | ||||
-rw-r--r-- | include/grpc++/impl/proto_utils.h | 4 | ||||
-rw-r--r-- | include/grpc++/impl/rpc_method.h | 14 | ||||
-rw-r--r-- | include/grpc++/impl/rpc_service_method.h | 24 | ||||
-rw-r--r-- | include/grpc++/impl/serialization_traits.h | 6 | ||||
-rw-r--r-- | include/grpc++/impl/service_type.h | 4 | ||||
-rw-r--r-- | include/grpc++/impl/sync.h | 2 | ||||
-rw-r--r-- | include/grpc++/impl/sync_no_cxx11.h | 8 | ||||
-rw-r--r-- | include/grpc++/impl/thd.h | 2 | ||||
-rw-r--r-- | include/grpc++/impl/thd_no_cxx11.h | 21 |
14 files changed, 75 insertions, 123 deletions
diff --git a/include/grpc++/impl/README.md b/include/grpc++/impl/README.md new file mode 100644 index 0000000000..612150caa0 --- /dev/null +++ b/include/grpc++/impl/README.md @@ -0,0 +1,4 @@ +**The APIs in this directory are not stable!** + +This directory contains header files that need to be installed but are not part +of the public API. Users should not use these headers directly. diff --git a/include/grpc++/impl/call.h b/include/grpc++/impl/call.h index d49102fa3e..e5da6c9e2a 100644 --- a/include/grpc++/impl/call.h +++ b/include/grpc++/impl/call.h @@ -34,18 +34,17 @@ #ifndef GRPCXX_IMPL_CALL_H #define GRPCXX_IMPL_CALL_H -#include <grpc/support/alloc.h> -#include <grpc++/client_context.h> -#include <grpc++/completion_queue.h> -#include <grpc++/config.h> -#include <grpc++/status.h> -#include <grpc++/impl/serialization_traits.h> - #include <functional> #include <memory> #include <map> +#include <cstring> -#include <string.h> +#include <grpc/support/alloc.h> +#include <grpc++/client_context.h> +#include <grpc++/completion_queue.h> +#include <grpc++/impl/serialization_traits.h> +#include <grpc++/support/config.h> +#include <grpc++/support/status.h> struct grpc_call; struct grpc_op; @@ -67,14 +66,10 @@ class WriteOptions { WriteOptions(const WriteOptions& other) : flags_(other.flags_) {} /// Clear all flags. - inline void Clear() { - flags_ = 0; - } + inline void Clear() { flags_ = 0; } /// Returns raw flags bitset. - inline gpr_uint32 flags() const { - return flags_; - } + inline gpr_uint32 flags() const { return flags_; } /// Sets flag for the disabling of compression for the next message write. /// @@ -122,9 +117,7 @@ class WriteOptions { /// not go out on the wire immediately. /// /// \sa GRPC_WRITE_BUFFER_HINT - inline bool get_buffer_hint() const { - return GetBit(GRPC_WRITE_BUFFER_HINT); - } + inline bool get_buffer_hint() const { return GetBit(GRPC_WRITE_BUFFER_HINT); } WriteOptions& operator=(const WriteOptions& rhs) { flags_ = rhs.flags_; @@ -132,17 +125,11 @@ class WriteOptions { } private: - void SetBit(const gpr_int32 mask) { - flags_ |= mask; - } + void SetBit(const gpr_int32 mask) { flags_ |= mask; } - void ClearBit(const gpr_int32 mask) { - flags_ &= ~mask; - } + void ClearBit(const gpr_int32 mask) { flags_ &= ~mask; } - bool GetBit(const gpr_int32 mask) const { - return flags_ & mask; - } + bool GetBit(const gpr_int32 mask) const { return flags_ & mask; } gpr_uint32 flags_; }; @@ -553,8 +540,7 @@ class CallOpSet : public CallOpSetInterface, template <class Op1 = CallNoOp<1>, class Op2 = CallNoOp<2>, class Op3 = CallNoOp<3>, class Op4 = CallNoOp<4>, class Op5 = CallNoOp<5>, class Op6 = CallNoOp<6>> -class SneakyCallOpSet GRPC_FINAL - : public CallOpSet<Op1, Op2, Op3, Op4, Op5, Op6> { +class SneakyCallOpSet : public CallOpSet<Op1, Op2, Op3, Op4, Op5, Op6> { public: bool FinalizeResult(void** tag, bool* status) GRPC_OVERRIDE { typedef CallOpSet<Op1, Op2, Op3, Op4, Op5, Op6> Base; diff --git a/include/grpc++/impl/client_unary_call.h b/include/grpc++/impl/client_unary_call.h index b77ce7d02c..4cdc800267 100644 --- a/include/grpc++/impl/client_unary_call.h +++ b/include/grpc++/impl/client_unary_call.h @@ -34,21 +34,20 @@ #ifndef GRPCXX_IMPL_CLIENT_UNARY_CALL_H #define GRPCXX_IMPL_CLIENT_UNARY_CALL_H -#include <grpc++/config.h> -#include <grpc++/status.h> - #include <grpc++/impl/call.h> +#include <grpc++/support/config.h> +#include <grpc++/support/status.h> namespace grpc { -class ChannelInterface; +class Channel; class ClientContext; class CompletionQueue; class RpcMethod; // Wrapper that performs a blocking unary call template <class InputMessage, class OutputMessage> -Status BlockingUnaryCall(ChannelInterface* channel, const RpcMethod& method, +Status BlockingUnaryCall(Channel* channel, const RpcMethod& method, ClientContext* context, const InputMessage& request, OutputMessage* result) { CompletionQueue cq; diff --git a/include/grpc++/impl/grpc_library.h b/include/grpc++/impl/grpc_library.h index f9fa677901..ce4211418d 100644 --- a/include/grpc++/impl/grpc_library.h +++ b/include/grpc++/impl/grpc_library.h @@ -46,5 +46,4 @@ class GrpcLibrary { } // namespace grpc - #endif // GRPCXX_IMPL_GRPC_LIBRARY_H diff --git a/include/grpc++/impl/internal_stub.h b/include/grpc++/impl/internal_stub.h deleted file mode 100644 index 370a3b8ac5..0000000000 --- a/include/grpc++/impl/internal_stub.h +++ /dev/null @@ -1,57 +0,0 @@ -/* - * - * Copyright 2015, Google Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are - * met: - * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following disclaimer - * in the documentation and/or other materials provided with the - * distribution. - * * Neither the name of Google Inc. nor the names of its - * contributors may be used to endorse or promote products derived from - * this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT - * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - */ - -#ifndef GRPCXX_IMPL_INTERNAL_STUB_H -#define GRPCXX_IMPL_INTERNAL_STUB_H - -#include <memory> - -#include <grpc++/channel_interface.h> - -namespace grpc { - -class InternalStub { - public: - InternalStub(const std::shared_ptr<ChannelInterface>& channel) - : channel_(channel) {} - virtual ~InternalStub() {} - - ChannelInterface* channel() { return channel_.get(); } - - private: - const std::shared_ptr<ChannelInterface> channel_; -}; - -} // namespace grpc - -#endif // GRPCXX_IMPL_INTERNAL_STUB_H diff --git a/include/grpc++/impl/proto_utils.h b/include/grpc++/impl/proto_utils.h index ebefa3e1be..283e33486d 100644 --- a/include/grpc++/impl/proto_utils.h +++ b/include/grpc++/impl/proto_utils.h @@ -38,8 +38,8 @@ #include <grpc/grpc.h> #include <grpc++/impl/serialization_traits.h> -#include <grpc++/config_protobuf.h> -#include <grpc++/status.h> +#include <grpc++/support/config_protobuf.h> +#include <grpc++/support/status.h> namespace grpc { diff --git a/include/grpc++/impl/rpc_method.h b/include/grpc++/impl/rpc_method.h index 50a160b08c..9800268062 100644 --- a/include/grpc++/impl/rpc_method.h +++ b/include/grpc++/impl/rpc_method.h @@ -34,6 +34,10 @@ #ifndef GRPCXX_IMPL_RPC_METHOD_H #define GRPCXX_IMPL_RPC_METHOD_H +#include <memory> + +#include <grpc++/channel.h> + namespace grpc { class RpcMethod { @@ -45,8 +49,14 @@ class RpcMethod { BIDI_STREAMING }; - RpcMethod(const char* name, RpcType type, void* channel_tag) - : name_(name), method_type_(type), channel_tag_(channel_tag) {} + RpcMethod(const char* name, RpcType type) + : name_(name), method_type_(type), channel_tag_(NULL) {} + + RpcMethod(const char* name, RpcType type, + const std::shared_ptr<Channel>& channel) + : name_(name), + method_type_(type), + channel_tag_(channel->RegisterMethod(name)) {} const char* name() const { return name_; } RpcType method_type() const { return method_type_; } diff --git a/include/grpc++/impl/rpc_service_method.h b/include/grpc++/impl/rpc_service_method.h index 925801e1ce..fcb0b7ccce 100644 --- a/include/grpc++/impl/rpc_service_method.h +++ b/include/grpc++/impl/rpc_service_method.h @@ -39,10 +39,10 @@ #include <memory> #include <vector> -#include <grpc++/config.h> #include <grpc++/impl/rpc_method.h> -#include <grpc++/status.h> -#include <grpc++/stream.h> +#include <grpc++/support/config.h> +#include <grpc++/support/status.h> +#include <grpc++/support/sync_stream.h> namespace grpc { class ServerContext; @@ -211,13 +211,19 @@ class BidiStreamingHandler : public MethodHandler { // Handle unknown method by returning UNIMPLEMENTED error. class UnknownMethodHandler : public MethodHandler { public: - void RunHandler(const HandlerParameter& param) GRPC_FINAL { + template <class T> + static void FillOps(ServerContext* context, T* ops) { Status status(StatusCode::UNIMPLEMENTED, ""); - CallOpSet<CallOpSendInitialMetadata, CallOpServerSendStatus> ops; - if (!param.server_context->sent_initial_metadata_) { - ops.SendInitialMetadata(param.server_context->initial_metadata_); + if (!context->sent_initial_metadata_) { + ops->SendInitialMetadata(context->initial_metadata_); + context->sent_initial_metadata_ = true; } - ops.ServerSendStatus(param.server_context->trailing_metadata_, status); + ops->ServerSendStatus(context->trailing_metadata_, status); + } + + void RunHandler(const HandlerParameter& param) GRPC_FINAL { + CallOpSet<CallOpSendInitialMetadata, CallOpServerSendStatus> ops; + FillOps(param.server_context, &ops); param.call->PerformOps(&ops); param.call->cq()->Pluck(&ops); } @@ -229,7 +235,7 @@ class RpcServiceMethod : public RpcMethod { // Takes ownership of the handler RpcServiceMethod(const char* name, RpcMethod::RpcType type, MethodHandler* handler) - : RpcMethod(name, type, nullptr), handler_(handler) {} + : RpcMethod(name, type), handler_(handler) {} MethodHandler* handler() { return handler_.get(); } diff --git a/include/grpc++/impl/serialization_traits.h b/include/grpc++/impl/serialization_traits.h index 1f5c674e4c..3ea66a3405 100644 --- a/include/grpc++/impl/serialization_traits.h +++ b/include/grpc++/impl/serialization_traits.h @@ -37,12 +37,12 @@ namespace grpc { /// Defines how to serialize and deserialize some type. -/// +/// /// Used for hooking different message serialization API's into GRPC. /// Each SerializationTraits implementation must provide the following /// functions: /// static Status Serialize(const Message& msg, -/// grpc_byte_buffer** buffer, +/// grpc_byte_buffer** buffer, // bool* own_buffer); /// static Status Deserialize(grpc_byte_buffer* buffer, /// Message* msg, @@ -57,7 +57,7 @@ namespace grpc { /// msg. max_message_size is passed in as a bound on the maximum number of /// message bytes Deserialize should accept. /// -/// Both functions return a Status, allowing them to explain what went +/// Both functions return a Status, allowing them to explain what went /// wrong if required. template <class Message, class UnusedButHereForPartialTemplateSpecialization = void> diff --git a/include/grpc++/impl/service_type.h b/include/grpc++/impl/service_type.h index c33a278f5b..3b6ac1de77 100644 --- a/include/grpc++/impl/service_type.h +++ b/include/grpc++/impl/service_type.h @@ -34,10 +34,10 @@ #ifndef GRPCXX_IMPL_SERVICE_TYPE_H #define GRPCXX_IMPL_SERVICE_TYPE_H -#include <grpc++/config.h> #include <grpc++/impl/serialization_traits.h> #include <grpc++/server.h> -#include <grpc++/status.h> +#include <grpc++/support/config.h> +#include <grpc++/support/status.h> namespace grpc { diff --git a/include/grpc++/impl/sync.h b/include/grpc++/impl/sync.h index 2f41d2bdeb..999c4303cb 100644 --- a/include/grpc++/impl/sync.h +++ b/include/grpc++/impl/sync.h @@ -34,7 +34,7 @@ #ifndef GRPCXX_IMPL_SYNC_H #define GRPCXX_IMPL_SYNC_H -#include <grpc++/config.h> +#include <grpc++/support/config.h> #ifdef GRPC_CXX0X_NO_THREAD #include <grpc++/impl/sync_no_cxx11.h> diff --git a/include/grpc++/impl/sync_no_cxx11.h b/include/grpc++/impl/sync_no_cxx11.h index 5869b04c76..120a031045 100644 --- a/include/grpc++/impl/sync_no_cxx11.h +++ b/include/grpc++/impl/sync_no_cxx11.h @@ -38,7 +38,7 @@ namespace grpc { -template<class mutex> +template <class mutex> class lock_guard; class condition_variable; @@ -46,6 +46,7 @@ class mutex { public: mutex() { gpr_mu_init(&mu_); } ~mutex() { gpr_mu_destroy(&mu_); } + private: ::gpr_mu mu_; template <class mutex> @@ -58,6 +59,7 @@ class lock_guard { public: lock_guard(mutex &mu) : mu_(mu), locked(true) { gpr_mu_lock(&mu.mu_); } ~lock_guard() { unlock_internal(); } + protected: void lock_internal() { if (!locked) gpr_mu_lock(&mu_.mu_); @@ -67,6 +69,7 @@ class lock_guard { if (locked) gpr_mu_unlock(&mu_.mu_); locked = false; } + private: mutex &mu_; bool locked; @@ -76,7 +79,7 @@ class lock_guard { template <class mutex> class unique_lock : public lock_guard<mutex> { public: - unique_lock(mutex &mu) : lock_guard<mutex>(mu) { } + unique_lock(mutex &mu) : lock_guard<mutex>(mu) {} void lock() { this->lock_internal(); } void unlock() { this->unlock_internal(); } }; @@ -92,6 +95,7 @@ class condition_variable { } void notify_one() { gpr_cv_signal(&cv_); } void notify_all() { gpr_cv_broadcast(&cv_); } + private: gpr_cv cv_; }; diff --git a/include/grpc++/impl/thd.h b/include/grpc++/impl/thd.h index 4c4578a92d..f8d4258ac6 100644 --- a/include/grpc++/impl/thd.h +++ b/include/grpc++/impl/thd.h @@ -34,7 +34,7 @@ #ifndef GRPCXX_IMPL_THD_H #define GRPCXX_IMPL_THD_H -#include <grpc++/config.h> +#include <grpc++/support/config.h> #ifdef GRPC_CXX0X_NO_THREAD #include <grpc++/impl/thd_no_cxx11.h> diff --git a/include/grpc++/impl/thd_no_cxx11.h b/include/grpc++/impl/thd_no_cxx11.h index a6bdd7dfe9..84d03ce184 100644 --- a/include/grpc++/impl/thd_no_cxx11.h +++ b/include/grpc++/impl/thd_no_cxx11.h @@ -40,7 +40,8 @@ namespace grpc { class thread { public: - template<class T> thread(void (T::*fptr)(), T *obj) { + template <class T> + thread(void (T::*fptr)(), T *obj) { func_ = new thread_function<T>(fptr, obj); joined_ = false; start(); @@ -53,28 +54,28 @@ class thread { gpr_thd_join(thd_); joined_ = true; } + private: void start() { gpr_thd_options options = gpr_thd_options_default(); gpr_thd_options_set_joinable(&options); - gpr_thd_new(&thd_, thread_func, (void *) func_, &options); + gpr_thd_new(&thd_, thread_func, (void *)func_, &options); } static void thread_func(void *arg) { - thread_function_base *func = (thread_function_base *) arg; + thread_function_base *func = (thread_function_base *)arg; func->call(); } class thread_function_base { public: - virtual ~thread_function_base() { } + virtual ~thread_function_base() {} virtual void call() = 0; }; - template<class T> + template <class T> class thread_function : public thread_function_base { public: - thread_function(void (T::*fptr)(), T *obj) - : fptr_(fptr) - , obj_(obj) { } + thread_function(void (T::*fptr)(), T *obj) : fptr_(fptr), obj_(obj) {} virtual void call() { (obj_->*fptr_)(); } + private: void (T::*fptr_)(); T *obj_; @@ -84,8 +85,8 @@ class thread { bool joined_; // Disallow copy and assign. - thread(const thread&); - void operator=(const thread&); + thread(const thread &); + void operator=(const thread &); }; } // namespace grpc |