/// <summary> /// 发送数据 /// </summary> private void trySend() { if (sending.IsClose) { return; } if (sending.IsSending) { return; } Ensure.IsNotNull(eventloop); eventloop.Execute(new ActionTask(() => { if (sendingBuffer.HasValue) { //从ChannelBuffer中获取需要发送的Block var block = sendingBuffer.GetSendingBlock(); //发送Block sending.Send(block); } else { sending.ExitSending(); } })); }
protected void execute(Action action) { Ensure.IsNotNull(action); if (eventloop.InEventloop) { action(); } else { eventloop.Execute(new ActionTask(action)); } }