From 5468c27841a2b4ec26b28a293fcff84e84d7822f Mon Sep 17 00:00:00 2001 From: Jan Tattermusch Date: Mon, 23 May 2016 15:18:35 -0400 Subject: [PATCH] reorder members for readability --- src/csharp/Grpc.Core/Internal/AsyncCall.cs | 52 +++++++++++----------- 1 file changed, 26 insertions(+), 26 deletions(-) diff --git a/src/csharp/Grpc.Core/Internal/AsyncCall.cs b/src/csharp/Grpc.Core/Internal/AsyncCall.cs index dec6eafd46e..ff70efc8b3e 100644 --- a/src/csharp/Grpc.Core/Internal/AsyncCall.cs +++ b/src/csharp/Grpc.Core/Internal/AsyncCall.cs @@ -336,6 +336,32 @@ namespace Grpc.Core.Internal get { return true; } } + protected override Task CheckSendAllowedOrEarlyResult() + { + CheckSendPreconditionsClientSide(); + + if (finishedStatus.HasValue) + { + // throwing RpcException if we already received status on client + // side makes the most sense. + // Note that this throws even for StatusCode.OK. + // Writing after the call has finished is not a programming error because server can close + // the call anytime, so don't throw directly, but let the write task finish with an error. + var tcs = new TaskCompletionSource(); + tcs.SetException(new RpcException(finishedStatus.Value.Status)); + return tcs.Task; + } + + return null; + } + + private void CheckSendPreconditionsClientSide() + { + CheckNotCancelled(); + GrpcPreconditions.CheckState(!halfcloseRequested, "Request stream has already been completed."); + GrpcPreconditions.CheckState(streamingWriteTcs == null, "Only one write can be pending at a time."); + } + private void Initialize(CompletionQueueSafeHandle cq) { using (Profilers.ForCurrentThread().NewScope("AsyncCall.Initialize")) @@ -437,32 +463,6 @@ namespace Grpc.Core.Internal } } - protected override Task CheckSendAllowedOrEarlyResult() - { - CheckSendPreconditionsClientSide(); - - if (finishedStatus.HasValue) - { - // throwing RpcException if we already received status on client - // side makes the most sense. - // Note that this throws even for StatusCode.OK. - // Writing after the call has finished is not a programming error because server can close - // the call anytime, so don't throw directly, but let the write task finish with an error. - var tcs = new TaskCompletionSource(); - tcs.SetException(new RpcException(finishedStatus.Value.Status)); - return tcs.Task; - } - - return null; - } - - private void CheckSendPreconditionsClientSide() - { - CheckNotCancelled(); - GrpcPreconditions.CheckState(!halfcloseRequested, "Request stream has already been completed."); - GrpcPreconditions.CheckState(streamingWriteTcs == null, "Only one write can be pending at a time."); - } - /// /// Handles receive status completion for calls with streaming response. ///