aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/csharp
diff options
context:
space:
mode:
authorGravatar Jan Tattermusch <jtattermusch@google.com>2016-05-25 17:56:18 -0700
committerGravatar Jan Tattermusch <jtattermusch@google.com>2016-05-25 18:00:38 -0700
commit5a94cf5eae67341ec1a59c13a35ce14116cc8413 (patch)
treec51414f1fe045427c514d818b6210142e84766da /src/csharp
parent2f0a690f997b1516d1eff37268620ef6d6aacc4e (diff)
use 1 cq per thread by default
Diffstat (limited to 'src/csharp')
-rw-r--r--src/csharp/Grpc.Core/GrpcEnvironment.cs15
1 files changed, 11 insertions, 4 deletions
diff --git a/src/csharp/Grpc.Core/GrpcEnvironment.cs b/src/csharp/Grpc.Core/GrpcEnvironment.cs
index 7fa06bf672..18af1099f1 100644
--- a/src/csharp/Grpc.Core/GrpcEnvironment.cs
+++ b/src/csharp/Grpc.Core/GrpcEnvironment.cs
@@ -47,7 +47,6 @@ namespace Grpc.Core
public class GrpcEnvironment
{
const int MinDefaultThreadPoolSize = 4;
- const int DefaultCompletionQueueCount = 1;
static object staticLock = new object();
static GrpcEnvironment instance;
@@ -166,9 +165,7 @@ namespace Grpc.Core
private GrpcEnvironment()
{
GrpcNativeInit();
-
- var cqCount = customCompletionQueueCount ?? DefaultCompletionQueueCount;
- threadPool = new GrpcThreadPool(this, GetThreadPoolSizeOrDefault(), cqCount);
+ threadPool = new GrpcThreadPool(this, GetThreadPoolSizeOrDefault(), GetCompletionQueueCountOrDefault());
threadPool.Start();
}
@@ -250,5 +247,15 @@ namespace Grpc.Core
// more work, but seems to work reasonably well for a start.
return Math.Max(MinDefaultThreadPoolSize, Environment.ProcessorCount / 2);
}
+
+ private int GetCompletionQueueCountOrDefault()
+ {
+ if (customCompletionQueueCount.HasValue)
+ {
+ return customCompletionQueueCount.Value;
+ }
+ // by default, create a completion queue for each thread
+ return GetThreadPoolSizeOrDefault();
+ }
}
}