예제 #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();
                }
            }));
        }
예제 #2
0
파일: Channel.cs 프로젝트: softchar/HiPush
        protected void execute(Action action) {
            Ensure.IsNotNull(action);

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

        }