diff options
Diffstat (limited to 'src/cpp/server')
-rw-r--r-- | src/cpp/server/create_default_thread_pool.cc | 6 | ||||
-rw-r--r-- | src/cpp/server/dynamic_thread_pool.cc | 24 | ||||
-rw-r--r-- | src/cpp/server/secure_server_credentials.cc | 4 | ||||
-rw-r--r-- | src/cpp/server/server_context.cc | 7 |
4 files changed, 24 insertions, 17 deletions
diff --git a/src/cpp/server/create_default_thread_pool.cc b/src/cpp/server/create_default_thread_pool.cc index 81c84474d8..9f59d254f1 100644 --- a/src/cpp/server/create_default_thread_pool.cc +++ b/src/cpp/server/create_default_thread_pool.cc @@ -39,9 +39,9 @@ namespace grpc { ThreadPoolInterface* CreateDefaultThreadPool() { - int cores = gpr_cpu_num_cores(); - if (!cores) cores = 4; - return new DynamicThreadPool(cores); + int cores = gpr_cpu_num_cores(); + if (!cores) cores = 4; + return new DynamicThreadPool(cores); } } // namespace grpc diff --git a/src/cpp/server/dynamic_thread_pool.cc b/src/cpp/server/dynamic_thread_pool.cc index f58d0420df..b475f43b1d 100644 --- a/src/cpp/server/dynamic_thread_pool.cc +++ b/src/cpp/server/dynamic_thread_pool.cc @@ -36,10 +36,10 @@ #include <grpc++/dynamic_thread_pool.h> namespace grpc { -DynamicThreadPool::DynamicThread::DynamicThread(DynamicThreadPool *pool): - pool_(pool), - thd_(new grpc::thread(&DynamicThreadPool::DynamicThread::ThreadFunc, this)) { -} +DynamicThreadPool::DynamicThread::DynamicThread(DynamicThreadPool* pool) + : pool_(pool), + thd_(new grpc::thread(&DynamicThreadPool::DynamicThread::ThreadFunc, + this)) {} DynamicThreadPool::DynamicThread::~DynamicThread() { thd_->join(); thd_.reset(); @@ -57,7 +57,7 @@ void DynamicThreadPool::DynamicThread::ThreadFunc() { pool_->shutdown_cv_.notify_one(); } } - + void DynamicThreadPool::ThreadFunc() { for (;;) { // Wait until work is available or we are shutting down. @@ -65,7 +65,7 @@ void DynamicThreadPool::ThreadFunc() { if (!shutdown_ && callbacks_.empty()) { // If there are too many threads waiting, then quit this thread if (threads_waiting_ >= reserve_threads_) { - break; + break; } threads_waiting_++; cv_.wait(lock); @@ -84,9 +84,11 @@ void DynamicThreadPool::ThreadFunc() { } } -DynamicThreadPool::DynamicThreadPool(int reserve_threads) : - shutdown_(false), reserve_threads_(reserve_threads), nthreads_(0), - threads_waiting_(0) { +DynamicThreadPool::DynamicThreadPool(int reserve_threads) + : shutdown_(false), + reserve_threads_(reserve_threads), + nthreads_(0), + threads_waiting_(0) { for (int i = 0; i < reserve_threads_; i++) { grpc::lock_guard<grpc::mutex> lock(mu_); nthreads_++; @@ -96,10 +98,10 @@ DynamicThreadPool::DynamicThreadPool(int reserve_threads) : void DynamicThreadPool::ReapThreads(std::list<DynamicThread*>* tlist) { for (auto t = tlist->begin(); t != tlist->end(); t = tlist->erase(t)) { - delete *t; + delete *t; } } - + DynamicThreadPool::~DynamicThreadPool() { grpc::unique_lock<grpc::mutex> lock(mu_); shutdown_ = true; diff --git a/src/cpp/server/secure_server_credentials.cc b/src/cpp/server/secure_server_credentials.cc index 32c45e2280..f203cf7f49 100644 --- a/src/cpp/server/secure_server_credentials.cc +++ b/src/cpp/server/secure_server_credentials.cc @@ -35,8 +35,8 @@ namespace grpc { -int SecureServerCredentials::AddPortToServer( - const grpc::string& addr, grpc_server* server) { +int SecureServerCredentials::AddPortToServer(const grpc::string& addr, + grpc_server* server) { return grpc_server_add_secure_http2_port(server, addr.c_str(), creds_); } diff --git a/src/cpp/server/server_context.cc b/src/cpp/server/server_context.cc index bb34040a2f..03461ddda5 100644 --- a/src/cpp/server/server_context.cc +++ b/src/cpp/server/server_context.cc @@ -50,7 +50,12 @@ namespace grpc { class ServerContext::CompletionOp GRPC_FINAL : public CallOpSetInterface { public: // initial refs: one in the server context, one in the cq - CompletionOp() : has_tag_(false), tag_(nullptr), refs_(2), finalized_(false), cancelled_(0) {} + CompletionOp() + : has_tag_(false), + tag_(nullptr), + refs_(2), + finalized_(false), + cancelled_(0) {} void FillOps(grpc_op* ops, size_t* nops) GRPC_OVERRIDE; bool FinalizeResult(void** tag, bool* status) GRPC_OVERRIDE; |