Skip to content
Snippets Groups Projects
Commit 5a94cf5e authored by Jan Tattermusch's avatar Jan Tattermusch
Browse files

use 1 cq per thread by default

parent 2f0a690f
No related branches found
No related tags found
No related merge requests found
......@@ -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();
}
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment