Beispiel #1
0
        protected MLink baseAddToFront()
        {
            // Are there any nodes on the Reserve list?
            if (this.pReserve == null)
            {
                // refill the reserve list by the refill size
                this.privFillReservedPool(this.mRefillSize);
            }

            // Always take from the reserve list
            MLink pNode = MLink.PullFromFront(ref this.pReserve);

            Debug.Assert(pNode != null);

            // Update stats
            this.mNumActive++;
            //update active high count if needed;
            if (this.mNumActive > this.mActiveHighCount)
            {
                this.mActiveHighCount = this.mNumActive;
            }
            this.mNumReserve--;

            // copy to active
            MLink.AddToFront(ref this.pActive, pNode);

            //Debug.WriteLine("Base Add Node called");

            // YES - here's your new one (may its reused from reserved)
            return(pNode);
        }
Beispiel #2
0
        private void privFillReservedPool(int count)
        {
            // doesn't make sense if its not at least 1
            Debug.Assert(count > 0);

            this.mTotalNodeCount += count;
            this.mNumReserve     += count;

            // Preload the reserve
            for (int i = 0; i < count; i++)
            {
                MLink pNode = this.derivedCreateNode();
                Debug.Assert(pNode != null);

                //add each newly created node to front of reserve list
                MLink.AddToFront(ref this.pReserve, pNode);
            }
        }
Beispiel #3
0
        protected void baseRemoveNode(MLink targetNode)
        {
            //make sure node exists
            Debug.Assert(targetNode != null);

            // Don't do the work here...
            // abstract/delegate it to DLink
            MLink.RemoveNode(ref this.pActive, targetNode);

            // wash node before returning to reserve list
            this.derivedWashNode(targetNode);

            // add pulled node to the reserve list
            MLink.AddToFront(ref this.pReserve, targetNode);

            // stats update
            this.mNumActive--;
            this.mNumReserve++;

            //Debug.WriteLine("Base Remove called");
        }