protected bool IncompleteWrite(bool scheduleAsync, SocketChannelAsyncOperation <TChannel, TUnsafe> operation) { // Did not write completely. if (scheduleAsync) { SetState(StateFlags.WriteScheduled); bool pending; using (ExecutionContext.IsFlowSuppressed() ? default(AsyncFlowControl?) : ExecutionContext.SuppressFlow()) { pending = Socket.SendAsync(operation); } if (!pending) { Unsafe.FinishWrite(operation); } return(pending); } else { // Schedule flush again later so other tasks can be picked up input the meantime EventLoop.Execute(FlushAction, this); return(true); } }
protected bool IncompleteWrite(bool scheduleAsync, SocketChannelAsyncOperation <TChannel, TUnsafe> operation) { // Did not write completely. if (scheduleAsync) { SetState(StateFlags.WriteScheduled); bool pending; #if NETCOREAPP || NETSTANDARD pending = Socket.SendAsync(operation); #else if (ExecutionContext.IsFlowSuppressed()) { pending = Socket.SendAsync(operation); } else { using (ExecutionContext.SuppressFlow()) { pending = Socket.SendAsync(operation); } } #endif if (!pending) { Unsafe.FinishWrite(operation); // ## 苦竹 修改 ## ((ISocketChannelUnsafe)this.Unsafe).FinishWrite(operation); } return(pending); } else { // Schedule flush again later so other tasks can be picked up input the meantime EventLoop.Execute(FlushAction, this); return(true); } }