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_builder.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_builder.h')
-rw-r--r-- | include/grpc++/server_builder.h | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/include/grpc++/server_builder.h b/include/grpc++/server_builder.h index e2bae4b41f..25bbacbbc7 100644 --- a/include/grpc++/server_builder.h +++ b/include/grpc++/server_builder.h @@ -20,6 +20,7 @@ #define GRPCXX_SERVER_BUILDER_H #include <climits> +#include <functional> #include <map> #include <memory> #include <vector> @@ -30,6 +31,7 @@ #include <grpc++/support/config.h> #include <grpc/compression.h> #include <grpc/support/cpu.h> +#include <grpc/support/thd.h> #include <grpc/support/useful.h> #include <grpc/support/workaround_list.h> @@ -47,6 +49,7 @@ class Service; namespace testing { class ServerBuilderPluginTest; +class ServerBuilderThreadCreatorOverrideTest; } // namespace testing /// A builder class for the creation and startup of \a grpc::Server instances. @@ -213,6 +216,17 @@ class ServerBuilder { private: friend class ::grpc::testing::ServerBuilderPluginTest; + friend class ::grpc::testing::ServerBuilderThreadCreatorOverrideTest; + + ServerBuilder& SetThreadFunctions( + 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) { + thread_creator_ = thread_creator; + thread_joiner_ = thread_joiner; + return *this; + } struct Port { grpc::string addr; @@ -272,6 +286,11 @@ class ServerBuilder { grpc_compression_algorithm algorithm; } maybe_default_compression_algorithm_; uint32_t enabled_compression_algorithms_bitset_; + + 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_; }; } // namespace grpc |