grpc
src
cpp
server
create_default_thread_pool.cc
Go to the documentation of this file.
1
/*
2
*
3
* Copyright 2015 gRPC authors.
4
*
5
* Licensed under the Apache License, Version 2.0 (the "License");
6
* you may not use this file except in compliance with the License.
7
* You may obtain a copy of the License at
8
*
9
* http://www.apache.org/licenses/LICENSE-2.0
10
*
11
* Unless required by applicable law or agreed to in writing, software
12
* distributed under the License is distributed on an "AS IS" BASIS,
13
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
* See the License for the specific language governing permissions and
15
* limitations under the License.
16
*
17
*/
18
19
#include <
grpc/support/cpu.h
>
20
21
#include "
src/cpp/server/dynamic_thread_pool.h
"
22
#include "
src/cpp/server/thread_pool_interface.h
"
23
24
#ifndef GRPC_CUSTOM_DEFAULT_THREAD_POOL
25
26
namespace
grpc
{
27
namespace
{
28
29
ThreadPoolInterface* CreateDefaultThreadPoolImpl() {
30
int
cores =
gpr_cpu_num_cores
();
31
if
(!cores) cores = 4;
32
return
new
DynamicThreadPool(cores);
33
}
34
35
CreateThreadPoolFunc
g_ctp_impl = CreateDefaultThreadPoolImpl;
36
37
}
// namespace
38
39
ThreadPoolInterface
*
CreateDefaultThreadPool
() {
return
g_ctp_impl(); }
40
41
void
SetCreateThreadPool
(
CreateThreadPoolFunc
func
) { g_ctp_impl =
func
; }
42
43
}
// namespace grpc
44
45
#endif // !GRPC_CUSTOM_DEFAULT_THREAD_POOL
gpr_cpu_num_cores
GPRAPI unsigned gpr_cpu_num_cores(void)
grpc
Definition:
grpcpp/alarm.h:33
grpc::ThreadPoolInterface
Definition:
thread_pool_interface.h:27
thread_pool_interface.h
cpu.h
grpc::SetCreateThreadPool
void SetCreateThreadPool(CreateThreadPoolFunc func)
Definition:
create_default_thread_pool.cc:41
grpc::CreateThreadPoolFunc
ThreadPoolInterface *(* CreateThreadPoolFunc)(void)
Definition:
thread_pool_interface.h:36
grpc::CreateDefaultThreadPool
ThreadPoolInterface * CreateDefaultThreadPool()
Definition:
create_default_thread_pool.cc:39
dynamic_thread_pool.h
func
const EVP_CIPHER *(* func)(void)
Definition:
cipher_extra.c:73
grpc
Author(s):
autogenerated on Fri May 16 2025 02:58:06