コード例 #1
0
 //-------------------------------------------------------------------------
 // 添加一个节点
 void _addNode(EbDoubleLinkNode <TObject> pnew, EbDoubleLinkNode <TObject> prev, EbDoubleLinkNode <TObject> next)
 {
     next.prev = pnew;
     pnew.next = next;
     pnew.prev = prev;
     prev.next = pnew;
 }
コード例 #2
0
 //-------------------------------------------------------------------------
 // 替换一个节点
 public void replaceNode(EbDoubleLinkNode <TObject> old, EbDoubleLinkNode <TObject> pnew)
 {
     pnew.next      = old.next;
     pnew.next.prev = pnew;
     pnew.prev      = old.prev;
     pnew.prev.next = pnew;
 }
コード例 #3
0
 //-------------------------------------------------------------------------
 // 删除一个节点
 static void _delNode(EbDoubleLinkNode <TObject> prev, EbDoubleLinkNode <TObject> next)
 {
     if (prev != null && next != null)
     {
         next.prev = prev;
         prev.next = next;
     }
 }
コード例 #4
0
ファイル: EbTimerShaft.cs プロジェクト: cyecp/GF.Core
        //-------------------------------------------------------------------------
        // 添加一个时间事件
        public void addTimer(EbTimeEvent time_event)
        {
            EbDoubleLinkNode <EbTimeEvent> timer_node = new EbDoubleLinkNode <EbTimeEvent>();

            timer_node.mObject = time_event;

            mMapEventNode[time_event] = timer_node;

            _addTimer(timer_node);
        }
コード例 #5
0
ファイル: EbTimerShaft.cs プロジェクト: cyecp/GF.Core
        //-------------------------------------------------------------------------
        // 删除一个时间事件
        public int delTimer(EbTimeEvent time_event)
        {
            if (mMapEventNode.ContainsKey(time_event))
            {
                EbDoubleLinkNode <EbTimeEvent> timer_node = mMapEventNode[time_event];

                _delTimer(timer_node);
            }

            return(0);
        }
コード例 #6
0
ファイル: EbTimerShaft.cs プロジェクト: cyecp/GF.Core
        //-------------------------------------------------------------------------
        // 添加事件
        void _addTimer(EbDoubleLinkNode <EbTimeEvent> timer)
        {
            ulong expires = timer.mObject.mExpires;

            ulong idx = expires - mTimeJeffies;

            EbDoubleLinkList <EbTimeEvent> list_timer_spoke = null;

            if (idx < MAX_WHEEL_SIZE)
            {// 第1个轮子
                ulong i = expires & MAX_WHEEL_MASK;
                list_timer_spoke = mWheel1.mListTimerSpoke[(int)i];
            }
            else if (idx < (ulong)1 << Convert.ToInt32(MAX_WHEEL + MIN_WHEEL))
            {// 第2个轮子
                ulong i = expires >> Convert.ToInt32(MAX_WHEEL) & MIN_WHEEL_MASK;
                list_timer_spoke = mWheel2.mListTimerSpoke[(int)i];
            }
            else if (idx < (ulong)1 << Convert.ToInt32(MAX_WHEEL + 2 * MIN_WHEEL))
            {// 第3个轮子
                ulong i = expires >> Convert.ToInt32(MAX_WHEEL + MIN_WHEEL) & MIN_WHEEL_MASK;
                list_timer_spoke = mWheel3.mListTimerSpoke[(int)i];
            }
            else if (idx < (ulong)1 << Convert.ToInt32(MAX_WHEEL + 3 * MIN_WHEEL))
            {// 第4个轮子
                ulong i = expires >> Convert.ToInt32(MAX_WHEEL + 2 * MIN_WHEEL) & MIN_WHEEL_MASK;
                list_timer_spoke = mWheel4.mListTimerSpoke[(int)i];
            }
            else if ((long)idx < 0)
            {
                // Can happen if you add a timer with expires == jiffies,
                // or you set a timer to go off in the past
                list_timer_spoke = mWheel1.mListTimerSpoke[(int)(mTimeJeffies & MAX_WHEEL_MASK)];
            }
            else
            {
                // If the timeout is larger than 0xffffffff on 64-bit
                // architectures then we use the maximum timeout:
                if (idx > 0xffffffffUL)
                {
                    idx     = 0xffffffffUL;
                    expires = idx + mTimeJeffies;
                }
                ulong i = expires >> Convert.ToInt32(MAX_WHEEL + 3 * MIN_WHEEL) & MIN_WHEEL_MASK;
                list_timer_spoke = mWheel5.mListTimerSpoke[(int)i];
            }

            // Timers are FIFO:
            list_timer_spoke.addTailNode(timer);
        }
コード例 #7
0
        //-------------------------------------------------------------------------
        // 添加队列到本队列(队尾)
        public void addTailList(EbDoubleLinkList <TObject> plist)
        {
            if (!plist.empty())
            {
                EbDoubleLinkNode <TObject> add_list_first = plist.firstNode();
                EbDoubleLinkNode <TObject> add_list_last  = plist.lastNode();
                plist.init();

                EbDoubleLinkNode <TObject> list_last = lastNode();
                list_last.next      = add_list_first;
                add_list_first.prev = list_last;
                add_list_last.next  = mpHead;
                mpHead.prev         = add_list_last;
            }
        }
コード例 #8
0
        //-------------------------------------------------------------------------
        public void destroy()
        {
            EbDoubleLinkNode <TObject> pnode = mpHead.next;

            do
            {
                if (pnode != mpHead)
                {
                    // 删除结点
                    delNode(pnode);

                    pnode = mpHead.next;
                }
            } while (pnode != mpHead);
        }
コード例 #9
0
        //-------------------------------------------------------------------------
        // 取得队列节点个数
        public uint getNodeCount()
        {
            EbDoubleLinkNode <TObject> pnode = mpHead.next;
            uint count = 0;

            do
            {
                if (pnode != mpHead)
                {
                    count++;
                    pnode = mpHead.next;
                }
            } while (pnode != mpHead);

            return(count);
        }
コード例 #10
0
 //-------------------------------------------------------------------------
 // 删除一个节点
 public static void delNode(EbDoubleLinkNode <TObject> entry)
 {
     _delNode(entry.prev, entry.next);
     entry.next = null;
     entry.prev = null;
 }
コード例 #11
0
 //-------------------------------------------------------------------------
 // 向队尾添加一个节点
 public void addTailNode(EbDoubleLinkNode <TObject> pnew)
 {
     _addNode(pnew, mpHead.prev, mpHead);
 }
コード例 #12
0
 //-------------------------------------------------------------------------
 // 向对头添加一个节点
 public void addNode(EbDoubleLinkNode <TObject> pnew)
 {
     _addNode(pnew, mpHead, mpHead.next);
 }
コード例 #13
0
 //-------------------------------------------------------------------------
 // 取得上一个节点
 public EbDoubleLinkNode <TObject> prevNode(EbDoubleLinkNode <TObject> pnode)
 {
     return(pnode.prev);
 }
コード例 #14
0
 //-------------------------------------------------------------------------
 // 取得下一个节点
 public EbDoubleLinkNode <TObject> nextNode(EbDoubleLinkNode <TObject> pnode)
 {
     return(pnode.next);
 }
コード例 #15
0
 //-------------------------------------------------------------------------
 public EbDoubleLinkList()
 {
     mpHead = new EbDoubleLinkNode <TObject>();
     init();
 }
コード例 #16
0
ファイル: EbTimerShaft.cs プロジェクト: cyecp/GF.Core
        //-------------------------------------------------------------------------
        // 删除事件
        int _delTimer(EbDoubleLinkNode <EbTimeEvent> timer)
        {
            EbDoubleLinkList <EbTimeEvent> .delNode(timer);

            return(0);
        }
コード例 #17
0
 //-------------------------------------------------------------------------
 // 最后一个节点
 public bool isLast(EbDoubleLinkNode <TObject> list)
 {
     return(list.next == mpHead);
 }