private void RefreshOwnedObjects(ThreadStack threadStack)
        {
            List <UInt64> newOwnedNodes = threadStack.SyncBlockObjectsOwned;

            int indexDelta = r_waitedOnNode.Ordinal;
            int countOld   = r_ownedNodes.Count;
            int countNew   = newOwnedNodes.Count;
            int to         = countNew;

            if (countNew < countOld)
            {
                for (int i = countNew; i < countOld; ++i)
                {
                    r_ownedNodes[countNew].Remove();
                    r_ownedNodes.RemoveAt(countNew);
                }
            }
            else if (countOld < countNew)
            {
                to = countOld;
                int index = countOld;

                for (int i = 0; i < (countNew - countOld); ++i)
                {
                    UInt64 objectAddress           = newOwnedNodes[index];
                    ThreadStackOwnedNode ownedNode = new ThreadStackOwnedNode(r_manager, r_threadStackNode, index + indexDelta, objectAddress);
                    r_ownedNodes.Add(ownedNode);
                    ++index;
                }
            }

            for (int i = 0; i < to; ++i)
            {
                r_ownedNodes[i].Refresh(newOwnedNodes[i]);
            }
        }
Пример #2
0
        private void RefreshOwnedObjects(ThreadStack threadStack)
        {
            List<UInt64> newOwnedNodes = threadStack.SyncBlockObjectsOwned;

            int indexDelta = r_waitedOnNode.Ordinal;
            int countOld = r_ownedNodes.Count;
            int countNew = newOwnedNodes.Count;
            int to = countNew;

            if (countNew < countOld)
            {
                for (int i = countNew; i < countOld; ++i)
                {
                    r_ownedNodes[countNew].Remove();
                    r_ownedNodes.RemoveAt(countNew);
                }
            }
            else if (countOld < countNew)
            {
                to = countOld;
                int index = countOld;

                for (int i = 0; i < (countNew - countOld); ++i)
                {
                    UInt64 objectAddress = newOwnedNodes[index];
                    ThreadStackOwnedNode ownedNode = new ThreadStackOwnedNode(r_manager, r_threadStackNode, index+indexDelta, objectAddress);
                    r_ownedNodes.Add(ownedNode);
                    ++index;
                }
            }

            for (int i = 0; i < to; ++i)
            {
                r_ownedNodes[i].Refresh(newOwnedNodes[i]);
            }
        }