aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorGravatar Vijay Pai <vpai@google.com>2018-11-08 10:12:09 -0800
committerGravatar Vijay Pai <vpai@google.com>2018-11-08 12:11:57 -0800
commit926b2941abd8363c656330a4923fca33bae4789c (patch)
treeee94d2d3a1c6c2fb852bc8f2cecb6d19cf38a1e6
parent3f34112d61e0b0cd2d7b9d7048a4b3360cd83412 (diff)
Pre-request 32 callbacks of each method
-rw-r--r--src/cpp/server/server_cc.cc12
1 files changed, 9 insertions, 3 deletions
diff --git a/src/cpp/server/server_cc.cc b/src/cpp/server/server_cc.cc
index c031528a8f..6e1adacc87 100644
--- a/src/cpp/server/server_cc.cc
+++ b/src/cpp/server/server_cc.cc
@@ -58,6 +58,9 @@ namespace {
// max-threads set) to the server builder.
#define DEFAULT_MAX_SYNC_SERVER_THREADS INT_MAX
+// How many callback requests of each method should we pre-register at start
+#define DEFAULT_CALLBACK_REQS_PER_METHOD 32
+
class DefaultGlobalCallbacks final : public Server::GlobalCallbacks {
public:
~DefaultGlobalCallbacks() override {}
@@ -769,9 +772,12 @@ bool Server::RegisterService(const grpc::string* host, Service* service) {
(*it)->AddSyncMethod(method, method_registration_tag);
}
} else {
- // a callback method
- auto* req = new CallbackRequest(this, method, method_registration_tag);
- callback_reqs_.emplace_back(req);
+ // a callback method. Register at least some callback requests
+ // TODO(vjpai): Register these dynamically based on need
+ for (int i = 0; i < DEFAULT_CALLBACK_REQS_PER_METHOD; i++) {
+ auto* req = new CallbackRequest(this, method, method_registration_tag);
+ callback_reqs_.emplace_back(req);
+ }
// Enqueue it so that it will be Request'ed later once
// all request matchers are created at core server startup
}