Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
G
Grpc
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
tci-gateway-module
Grpc
Commits
50791829
Commit
50791829
authored
7 years ago
by
Noah Eisen
Committed by
GitHub
7 years ago
Browse files
Options
Downloads
Plain Diff
Merge pull request #11693 from ncteisen/refactor-thread-pool
Make CreateThreadPool Settable
parents
37e06cfc
eb70b9e0
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/cpp/server/create_default_thread_pool.cc
+10
-1
10 additions, 1 deletion
src/cpp/server/create_default_thread_pool.cc
src/cpp/server/thread_pool_interface.h
+4
-0
4 additions, 0 deletions
src/cpp/server/thread_pool_interface.h
with
14 additions
and
1 deletion
src/cpp/server/create_default_thread_pool.cc
+
10
−
1
View file @
50791829
...
...
@@ -23,13 +23,22 @@
#ifndef GRPC_CUSTOM_DEFAULT_THREAD_POOL
namespace
grpc
{
namespace
{
ThreadPoolInterface
*
CreateDefaultThreadPool
()
{
ThreadPoolInterface
*
CreateDefaultThreadPool
Impl
()
{
int
cores
=
gpr_cpu_num_cores
();
if
(
!
cores
)
cores
=
4
;
return
new
DynamicThreadPool
(
cores
);
}
CreateThreadPoolFunc
g_ctp_impl
=
CreateDefaultThreadPoolImpl
;
}
// namespace
ThreadPoolInterface
*
CreateDefaultThreadPool
()
{
return
g_ctp_impl
();
}
void
SetCreateThreadPool
(
CreateThreadPoolFunc
func
)
{
g_ctp_impl
=
func
;
}
}
// namespace grpc
#endif // !GRPC_CUSTOM_DEFAULT_THREAD_POOL
This diff is collapsed.
Click to expand it.
src/cpp/server/thread_pool_interface.h
+
4
−
0
View file @
50791829
...
...
@@ -32,6 +32,10 @@ class ThreadPoolInterface {
virtual
void
Add
(
const
std
::
function
<
void
()
>&
callback
)
=
0
;
};
// Allows different codebases to use their own thread pool impls
typedef
ThreadPoolInterface
*
(
*
CreateThreadPoolFunc
)(
void
);
void
SetCreateThreadPool
(
CreateThreadPoolFunc
func
);
ThreadPoolInterface
*
CreateDefaultThreadPool
();
}
// namespace grpc
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment