diff options
author | Craig Tiller <ctiller@google.com> | 2015-02-12 11:38:36 -0800 |
---|---|---|
committer | Craig Tiller <ctiller@google.com> | 2015-02-12 11:38:36 -0800 |
commit | 8c8d0aa1d881fbcf393a73f99b86ed29a866f8ff (patch) | |
tree | e26e0eb8c3f6fec55a917f1449883cc2da0a2153 /include/grpc++ | |
parent | bc8e3db73eecec79e5592c1e1723f6b69095e84a (diff) |
Async API progress
Diffstat (limited to 'include/grpc++')
-rw-r--r-- | include/grpc++/impl/service_type.h | 18 | ||||
-rw-r--r-- | include/grpc++/server.h | 3 | ||||
-rw-r--r-- | include/grpc++/server_builder.h | 7 |
3 files changed, 22 insertions, 6 deletions
diff --git a/include/grpc++/impl/service_type.h b/include/grpc++/impl/service_type.h index 0684f322d8..30654553ad 100644 --- a/include/grpc++/impl/service_type.h +++ b/include/grpc++/impl/service_type.h @@ -37,19 +37,29 @@ namespace grpc { class RpcService; +class Server; class SynchronousService { public: virtual ~SynchronousService() {} - virtual RpcService *service() = 0; + virtual RpcService* service() = 0; }; class AsynchronousService { public: - virtual ~AsynchronousService() {} - virtual RpcService *service() = 0; + AsynchronousService(CompletionQueue* cq, const char** method_names, size_t method_count) : cq_(cq), method_names_(method_names), method_count_(method_count) {} + + CompletionQueue* completion_queue() const { return cq_; } + + private: + friend class Server; + CompletionQueue* const cq_; + Server* server_ = nullptr; + const char**const method_names_; + size_t method_count_; + std::vector<void*> request_args_; }; } // namespace grpc -#endif // __GRPCPP_IMPL_SERVICE_TYPE_H__
\ No newline at end of file +#endif // __GRPCPP_IMPL_SERVICE_TYPE_H__
\ No newline at end of file diff --git a/include/grpc++/server.h b/include/grpc++/server.h index 98f3f17197..77aac75076 100644 --- a/include/grpc++/server.h +++ b/include/grpc++/server.h @@ -53,7 +53,7 @@ class Message; } // namespace google namespace grpc { -class AsyncServerContext; +class AsynchronousService; class RpcService; class RpcServiceMethod; class ServerCredentials; @@ -79,6 +79,7 @@ class Server final : private CallHook { // Register a service. This call does not take ownership of the service. // The service must exist for the lifetime of the Server instance. bool RegisterService(RpcService* service); + bool RegisterAsyncService(AsynchronousService* service); // Add a listening port. Can be called multiple times. int AddPort(const grpc::string& addr); // Start the server. diff --git a/include/grpc++/server_builder.h b/include/grpc++/server_builder.h index 8b4c81bc87..a550a53afb 100644 --- a/include/grpc++/server_builder.h +++ b/include/grpc++/server_builder.h @@ -42,6 +42,7 @@ namespace grpc { class AsynchronousService; +class CompletionQueue; class RpcService; class Server; class ServerCredentials; @@ -57,7 +58,11 @@ class ServerBuilder { // BuildAndStart(). void RegisterService(SynchronousService* service); - void RegisterAsyncService(AsynchronousService *service); + // Register an asynchronous service. New calls will be delevered to cq. + // This call does not take ownership of the service or completion queue. + // The service and completion queuemust exist for the lifetime of the Server + // instance returned by BuildAndStart(). + void RegisterAsyncService(AsynchronousService* service); // Add a listening port. Can be called multiple times. void AddPort(const grpc::string& addr); |