diff options
author | Vijay Pai <vpai@google.com> | 2017-11-14 19:04:02 -0800 |
---|---|---|
committer | Vijay Pai <vpai@google.com> | 2018-01-08 10:02:38 -0800 |
commit | 5dd32268be62114e8a7c81d60c0dc2633fb83081 (patch) | |
tree | 5d97aa70dfc6ea09df7da9e7955866d7574cb1e3 /include/grpc++/server.h | |
parent | 669900c7de64d5992c92a838e23097b27e09d0b5 (diff) |
Switch C++ sync server to use gpr_thd rather than std::thread and provide resource exhaustion mechanism
Diffstat (limited to 'include/grpc++/server.h')
-rw-r--r-- | include/grpc++/server.h | 18 |
1 files changed, 17 insertions, 1 deletions
diff --git a/include/grpc++/server.h b/include/grpc++/server.h index 01c4a60d21..456603e4e7 100644 --- a/include/grpc++/server.h +++ b/include/grpc++/server.h @@ -35,6 +35,7 @@ #include <grpc++/support/config.h> #include <grpc++/support/status.h> #include <grpc/compression.h> +#include <grpc/support/thd.h> struct grpc_server; @@ -138,10 +139,17 @@ class Server final : public ServerInterface, private GrpcLibraryCodegen { /// /// \param sync_cq_timeout_msec The timeout to use when calling AsyncNext() on /// server completion queues passed via sync_server_cqs param. + /// + /// \param thread_creator The thread creation function for the sync + /// server. Typically gpr_thd_new Server(int max_message_size, ChannelArguments* args, std::shared_ptr<std::vector<std::unique_ptr<ServerCompletionQueue>>> sync_server_cqs, - int min_pollers, int max_pollers, int sync_cq_timeout_msec); + int min_pollers, int max_pollers, int sync_cq_timeout_msec, + std::function<int(gpr_thd_id*, const char*, void (*)(void*), void*, + const gpr_thd_options*)> + thread_creator, + std::function<void(gpr_thd_id)> thread_joiner); /// Register a service. This call does not take ownership of the service. /// The service must exist for the lifetime of the Server instance. @@ -220,6 +228,14 @@ class Server final : public ServerInterface, private GrpcLibraryCodegen { std::unique_ptr<HealthCheckServiceInterface> health_check_service_; bool health_check_service_disabled_; + + std::function<int(gpr_thd_id*, const char*, void (*)(void*), void*, + const gpr_thd_options*)> + thread_creator_; + std::function<void(gpr_thd_id)> thread_joiner_; + + // A special handler for resource exhausted in sync case + std::unique_ptr<internal::MethodHandler> resource_exhausted_handler_; }; } // namespace grpc |