Skip to content
Snippets Groups Projects
Commit 1f3e6c1e authored by Vijay Pai's avatar Vijay Pai
Browse files

Start switching everything to dynamic pool

parent b76f3ada
No related branches found
No related tags found
No related merge requests found
...@@ -32,7 +32,7 @@ ...@@ -32,7 +32,7 @@
*/ */
#include <grpc/support/cpu.h> #include <grpc/support/cpu.h>
#include <grpc++/fixed_size_thread_pool.h> #include <grpc++/dynamic_thread_pool.h>
#ifndef GRPC_CUSTOM_DEFAULT_THREAD_POOL #ifndef GRPC_CUSTOM_DEFAULT_THREAD_POOL
...@@ -41,7 +41,7 @@ namespace grpc { ...@@ -41,7 +41,7 @@ namespace grpc {
ThreadPoolInterface* CreateDefaultThreadPool() { ThreadPoolInterface* CreateDefaultThreadPool() {
int cores = gpr_cpu_num_cores(); int cores = gpr_cpu_num_cores();
if (!cores) cores = 4; if (!cores) cores = 4;
return new FixedSizeThreadPool(cores); return new DynamicThreadPool(cores);
} }
} // namespace grpc } // namespace grpc
......
...@@ -45,7 +45,7 @@ ...@@ -45,7 +45,7 @@
#include <grpc++/client_context.h> #include <grpc++/client_context.h>
#include <grpc++/create_channel.h> #include <grpc++/create_channel.h>
#include <grpc++/credentials.h> #include <grpc++/credentials.h>
#include <grpc++/fixed_size_thread_pool.h> #include <grpc++/dynamic_thread_pool.h>
#include <grpc++/server.h> #include <grpc++/server.h>
#include <grpc++/server_builder.h> #include <grpc++/server_builder.h>
#include <grpc++/server_context.h> #include <grpc++/server_context.h>
...@@ -263,7 +263,7 @@ class End2endTest : public ::testing::Test { ...@@ -263,7 +263,7 @@ class End2endTest : public ::testing::Test {
TestServiceImpl service_; TestServiceImpl service_;
TestServiceImpl special_service_; TestServiceImpl special_service_;
TestServiceImplDupPkg dup_pkg_service_; TestServiceImplDupPkg dup_pkg_service_;
FixedSizeThreadPool thread_pool_; DynamicThreadPool thread_pool_;
}; };
static void SendRpc(grpc::cpp::test::util::TestService::Stub* stub, static void SendRpc(grpc::cpp::test::util::TestService::Stub* stub,
......
...@@ -42,7 +42,7 @@ ...@@ -42,7 +42,7 @@
#include <grpc++/client_context.h> #include <grpc++/client_context.h>
#include <grpc++/create_channel.h> #include <grpc++/create_channel.h>
#include <grpc++/credentials.h> #include <grpc++/credentials.h>
#include <grpc++/fixed_size_thread_pool.h> #include <grpc++/dynamic_thread_pool.h>
#include <grpc++/server.h> #include <grpc++/server.h>
#include <grpc++/server_builder.h> #include <grpc++/server_builder.h>
#include <grpc++/server_context.h> #include <grpc++/server_context.h>
...@@ -260,7 +260,7 @@ class MockTest : public ::testing::Test { ...@@ -260,7 +260,7 @@ class MockTest : public ::testing::Test {
std::unique_ptr<Server> server_; std::unique_ptr<Server> server_;
std::ostringstream server_address_; std::ostringstream server_address_;
TestServiceImpl service_; TestServiceImpl service_;
FixedSizeThreadPool thread_pool_; DynamicThreadPool thread_pool_;
}; };
// Do one real rpc and one mocked one // Do one real rpc and one mocked one
......
...@@ -43,7 +43,7 @@ ...@@ -43,7 +43,7 @@
#include <grpc++/client_context.h> #include <grpc++/client_context.h>
#include <grpc++/create_channel.h> #include <grpc++/create_channel.h>
#include <grpc++/credentials.h> #include <grpc++/credentials.h>
#include <grpc++/fixed_size_thread_pool.h> #include <grpc++/dynamic_thread_pool.h>
#include <grpc++/server.h> #include <grpc++/server.h>
#include <grpc++/server_builder.h> #include <grpc++/server_builder.h>
#include <grpc++/server_context.h> #include <grpc++/server_context.h>
...@@ -208,7 +208,7 @@ class End2endTest : public ::testing::Test { ...@@ -208,7 +208,7 @@ class End2endTest : public ::testing::Test {
const int kMaxMessageSize_; const int kMaxMessageSize_;
TestServiceImpl service_; TestServiceImpl service_;
TestServiceImplDupPkg dup_pkg_service_; TestServiceImplDupPkg dup_pkg_service_;
FixedSizeThreadPool thread_pool_; DynamicThreadPool thread_pool_;
}; };
static void SendRpc(grpc::cpp::test::util::TestService::Stub* stub, static void SendRpc(grpc::cpp::test::util::TestService::Stub* stub,
......
...@@ -45,7 +45,6 @@ ...@@ -45,7 +45,6 @@
#include <grpc/support/host_port.h> #include <grpc/support/host_port.h>
#include <grpc++/async_unary_call.h> #include <grpc++/async_unary_call.h>
#include <grpc++/config.h> #include <grpc++/config.h>
#include <grpc++/fixed_size_thread_pool.h>
#include <grpc++/server.h> #include <grpc++/server.h>
#include <grpc++/server_builder.h> #include <grpc++/server_builder.h>
#include <grpc++/server_context.h> #include <grpc++/server_context.h>
......
...@@ -40,6 +40,7 @@ ...@@ -40,6 +40,7 @@
#include <grpc/support/alloc.h> #include <grpc/support/alloc.h>
#include <grpc/support/host_port.h> #include <grpc/support/host_port.h>
#include <grpc++/config.h> #include <grpc++/config.h>
#include <grpc++/dynamic_thread_pool.h>
#include <grpc++/fixed_size_thread_pool.h> #include <grpc++/fixed_size_thread_pool.h>
#include <grpc++/server.h> #include <grpc++/server.h>
#include <grpc++/server_builder.h> #include <grpc++/server_builder.h>
...@@ -92,7 +93,13 @@ class TestServiceImpl GRPC_FINAL : public TestService::Service { ...@@ -92,7 +93,13 @@ class TestServiceImpl GRPC_FINAL : public TestService::Service {
class SynchronousServer GRPC_FINAL : public grpc::testing::Server { class SynchronousServer GRPC_FINAL : public grpc::testing::Server {
public: public:
SynchronousServer(const ServerConfig& config, int port) SynchronousServer(const ServerConfig& config, int port)
: thread_pool_(config.threads()), impl_(MakeImpl(port)) {} : thread_pool_(), impl_(MakeImpl(port)) {
if (config.threads() > 0) {
thread_pool_.reset(new FixedSizeThreadPool(config.threads()));
} else {
thread_pool_.reset(new DynamicThreadPool(-config.threads()));
}
}
private: private:
std::unique_ptr<grpc::Server> MakeImpl(int port) { std::unique_ptr<grpc::Server> MakeImpl(int port) {
...@@ -105,13 +112,13 @@ class SynchronousServer GRPC_FINAL : public grpc::testing::Server { ...@@ -105,13 +112,13 @@ class SynchronousServer GRPC_FINAL : public grpc::testing::Server {
builder.RegisterService(&service_); builder.RegisterService(&service_);
builder.SetThreadPool(&thread_pool_); builder.SetThreadPool(thread_pool_.get());
return builder.BuildAndStart(); return builder.BuildAndStart();
} }
TestServiceImpl service_; TestServiceImpl service_;
FixedSizeThreadPool thread_pool_; std::unique_ptr<ThreadPoolInterface> thread_pool_;
std::unique_ptr<grpc::Server> impl_; std::unique_ptr<grpc::Server> impl_;
}; };
......
...@@ -39,7 +39,7 @@ ...@@ -39,7 +39,7 @@
#include <grpc++/client_context.h> #include <grpc++/client_context.h>
#include <grpc++/create_channel.h> #include <grpc++/create_channel.h>
#include <grpc++/credentials.h> #include <grpc++/credentials.h>
#include <grpc++/fixed_size_thread_pool.h> #include <grpc++/dynamic_thread_pool.h>
#include <grpc++/server.h> #include <grpc++/server.h>
#include <grpc++/server_builder.h> #include <grpc++/server_builder.h>
#include <grpc++/server_context.h> #include <grpc++/server_context.h>
...@@ -102,7 +102,7 @@ class CliCallTest : public ::testing::Test { ...@@ -102,7 +102,7 @@ class CliCallTest : public ::testing::Test {
std::unique_ptr<Server> server_; std::unique_ptr<Server> server_;
std::ostringstream server_address_; std::ostringstream server_address_;
TestServiceImpl service_; TestServiceImpl service_;
FixedSizeThreadPool thread_pool_; DynamicThreadPool thread_pool_;
}; };
// Send a rpc with a normal stub and then a CliCall. Verify they match. // Send a rpc with a normal stub and then a CliCall. Verify they match.
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment