Пример #1
0
        //same as Manager
        protected CLink baseAddToFront()
        {
            // Are there any nodes on the Reserve list?
            if (this.pReserve == null)
            {
                // refill the reserve list by the DeltaGrow
                this.privFillReservedPool(this.mRefillSize);
            }

            // Always take from the reserve list
            CLink pNode = CLink.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
            CLink.AddToFront(ref this.pActive, pNode);

            // YES - here's your new one (may its reused from reserved)
            return(pNode);
        }
Пример #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++)
            {
                CLink pNode = this.derivedCreateNode();
                Debug.Assert(pNode != null);

                CLink.AddToFront(ref this.pReserve, pNode);
            }
        }
Пример #3
0
        protected void baseRemoveNode(CLink pNode)
        {
            Debug.Assert(pNode != null);

            // Don't do the work here... delegate it
            CLink.RemoveNode(ref this.pActive, pNode);

            // wash it before returning to reserve list
            this.derivedWashNode(pNode);

            // add it to the return list
            CLink.AddToFront(ref this.pReserve, pNode);

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