Exemple #1
0
        /// <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();
                }
            }));
        }
Exemple #2
0
        protected void execute(Action action) {
            Ensure.IsNotNull(action);

            if (eventloop.InEventloop) {
                action();
            } else {
                eventloop.Execute(new ActionTask(action));
            }

        }