diff options
Diffstat (limited to 'src/csharp/GrpcCore/Internal/GrpcThreadPool.cs')
-rw-r--r-- | src/csharp/GrpcCore/Internal/GrpcThreadPool.cs | 47 |
1 files changed, 5 insertions, 42 deletions
diff --git a/src/csharp/GrpcCore/Internal/GrpcThreadPool.cs b/src/csharp/GrpcCore/Internal/GrpcThreadPool.cs index f8154fa250..634a0b2d72 100644 --- a/src/csharp/GrpcCore/Internal/GrpcThreadPool.cs +++ b/src/csharp/GrpcCore/Internal/GrpcThreadPool.cs @@ -48,7 +48,6 @@ namespace Google.GRPC.Core.Internal readonly object myLock = new object(); readonly List<Thread> threads = new List<Thread>(); readonly int poolSize; - readonly Action<EventSafeHandle> eventHandler; CompletionQueueSafeHandle cq; @@ -56,11 +55,6 @@ namespace Google.GRPC.Core.Internal this.poolSize = poolSize; } - internal GrpcThreadPool(int poolSize, Action<EventSafeHandle> eventHandler) { - this.poolSize = poolSize; - this.eventHandler = eventHandler; - } - public void Start() { lock (myLock) @@ -104,34 +98,19 @@ namespace Google.GRPC.Core.Internal } } - private Thread CreateAndStartThread(int i) { - Action body; - if (eventHandler != null) - { - body = ThreadBodyWithHandler; - } - else - { - body = ThreadBodyNoHandler; - } - var thread = new Thread(new ThreadStart(body)); + private Thread CreateAndStartThread(int i) + { + var thread = new Thread(new ThreadStart(RunHandlerLoop)); thread.IsBackground = false; thread.Start(); - if (eventHandler != null) - { - thread.Name = "grpc_server_newrpc " + i; - } - else - { - thread.Name = "grpc " + i; - } + thread.Name = "grpc " + i; return thread; } /// <summary> /// Body of the polling thread. /// </summary> - private void ThreadBodyNoHandler() + private void RunHandlerLoop() { GRPCCompletionType completionType; do @@ -140,22 +119,6 @@ namespace Google.GRPC.Core.Internal } while(completionType != GRPCCompletionType.GRPC_QUEUE_SHUTDOWN); Console.WriteLine("Completion queue has shutdown successfully, thread " + Thread.CurrentThread.Name + " exiting."); } - - /// <summary> - /// Body of the polling thread. - /// </summary> - private void ThreadBodyWithHandler() - { - GRPCCompletionType completionType; - do - { - using (EventSafeHandle ev = cq.Next(Timespec.InfFuture)) { - completionType = ev.GetCompletionType(); - eventHandler(ev); - } - } while(completionType != GRPCCompletionType.GRPC_QUEUE_SHUTDOWN); - Console.WriteLine("Completion queue has shutdown successfully, thread " + Thread.CurrentThread.Name + " exiting."); - } } } |