diff options
author | Craig Tiller <craig.tiller@gmail.com> | 2015-06-09 22:57:45 -0700 |
---|---|---|
committer | Craig Tiller <craig.tiller@gmail.com> | 2015-06-09 22:57:45 -0700 |
commit | 7f79750bb585c2952b8cf29e323799feb4f82f62 (patch) | |
tree | d5887658de04191f890d9f343ab5cf18d5f2bb88 /src/csharp/Grpc.Core/Internal/GrpcThreadPool.cs | |
parent | 97f1454fc5ccdfc57e2f1296a52f1f83037cfd78 (diff) | |
parent | 36092008c694ff701f5a6f6edeebd37efbe06012 (diff) |
Merge pull request #12 from jtattermusch/you-complete-me-csharp
C# shutdown take 2
Diffstat (limited to 'src/csharp/Grpc.Core/Internal/GrpcThreadPool.cs')
-rw-r--r-- | src/csharp/Grpc.Core/Internal/GrpcThreadPool.cs | 20 |
1 files changed, 17 insertions, 3 deletions
diff --git a/src/csharp/Grpc.Core/Internal/GrpcThreadPool.cs b/src/csharp/Grpc.Core/Internal/GrpcThreadPool.cs index f4224668f1..89b44a4e2b 100644 --- a/src/csharp/Grpc.Core/Internal/GrpcThreadPool.cs +++ b/src/csharp/Grpc.Core/Internal/GrpcThreadPool.cs @@ -112,12 +112,26 @@ namespace Grpc.Core.Internal /// </summary> private void RunHandlerLoop() { - GRPCCompletionType completionType; + CompletionQueueEvent ev; do { - completionType = cq.NextWithCallback(); + ev = cq.Next(); + if (ev.type == GRPCCompletionType.OpComplete) + { + bool success = (ev.success != 0); + IntPtr tag = ev.tag; + try + { + var callback = GrpcEnvironment.CompletionRegistry.Extract(tag); + callback(success); + } + catch (Exception e) + { + Console.WriteLine("Exception occured while invoking completion delegate: " + e); + } + } } - while (completionType != GRPCCompletionType.GRPC_QUEUE_SHUTDOWN); + while (ev.type != GRPCCompletionType.Shutdown); Console.WriteLine("Completion queue has shutdown successfully, thread " + Thread.CurrentThread.Name + " exiting."); } } |