diff options
Diffstat (limited to 'include')
-rw-r--r-- | include/grpc++/impl/rpc_service_method.h | 3 | ||||
-rw-r--r-- | include/grpc++/impl/service_type.h | 13 |
2 files changed, 14 insertions, 2 deletions
diff --git a/include/grpc++/impl/rpc_service_method.h b/include/grpc++/impl/rpc_service_method.h index c6451dcbc3..3b47a4d64d 100644 --- a/include/grpc++/impl/rpc_service_method.h +++ b/include/grpc++/impl/rpc_service_method.h @@ -48,8 +48,6 @@ namespace grpc { class ServerContext; class StreamContextInterface; -// TODO(rocking): we might need to split this file into multiple ones. - // Base class for running an RPC handler. class MethodHandler { public: @@ -82,6 +80,7 @@ class RpcServiceMethod : public RpcMethod { void* server_tag() const { return server_tag_; } // if MethodHandler is nullptr, then this is an async method MethodHandler* handler() const { return handler_.get(); } + void ResetHandler() { handler_.reset(); } private: void* server_tag_; diff --git a/include/grpc++/impl/service_type.h b/include/grpc++/impl/service_type.h index 96b42c94fe..655aa91cdc 100644 --- a/include/grpc++/impl/service_type.h +++ b/include/grpc++/impl/service_type.h @@ -61,6 +61,7 @@ class ServerAsyncStreamingInterface { class Service { public: + Service() : server_(nullptr) {} virtual ~Service() {} bool has_async_methods() const { @@ -117,6 +118,18 @@ class Service { notification_cq, tag); } + void AddMethod(RpcServiceMethod* method) { methods_.emplace_back(method); } + + void MarkMethodAsync(const grpc::string& method_name) { + for (auto it = methods_.begin(); it != methods_.end(); ++it) { + if ((*it)->name() == method_name) { + (*it)->ResetHandler(); + return; + } + } + abort(); + } + private: friend class Server; |