From bc1283c43b2e568a5d1dd690fd40a6cb634536fc Mon Sep 17 00:00:00 2001 From: Jan Tattermusch Date: Wed, 24 Jul 2019 07:39:43 -0400 Subject: [PATCH] forbid BeginOp and EndOp for sync completion queue altogether --- .../Internal/CompletionQueueSafeHandle.cs | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) diff --git a/src/csharp/Grpc.Core/Internal/CompletionQueueSafeHandle.cs b/src/csharp/Grpc.Core/Internal/CompletionQueueSafeHandle.cs index 25540b40a10..6103ba99aab 100644 --- a/src/csharp/Grpc.Core/Internal/CompletionQueueSafeHandle.cs +++ b/src/csharp/Grpc.Core/Internal/CompletionQueueSafeHandle.cs @@ -104,20 +104,16 @@ namespace Grpc.Core.Internal private void BeginOp() { - if (shutdownRefcount != null) - { - bool success = false; - shutdownRefcount.IncrementIfNonzero(ref success); - GrpcPreconditions.CheckState(success, "Shutdown has already been called"); - } + GrpcPreconditions.CheckNotNull(shutdownRefcount, nameof(shutdownRefcount)); + bool success = false; + shutdownRefcount.IncrementIfNonzero(ref success); + GrpcPreconditions.CheckState(success, "Shutdown has already been called"); } private void EndOp() { - if (shutdownRefcount != null) - { - DecrementShutdownRefcount(); - } + GrpcPreconditions.CheckNotNull(shutdownRefcount, nameof(shutdownRefcount)); + DecrementShutdownRefcount(); } // Allows declaring BeginOp and EndOp of a completion queue with a using statement.