// Token: 0x06007700 RID: 30464 RVA: 0x002200BC File Offset: 0x0021E2BC
        internal bool Purge()
        {
            int count = this._inactiveViewTables.Count;

            if (count > 0)
            {
                ViewTable[] array = new ViewTable[count];
                this._inactiveViewTables.Keys.CopyTo(array, 0);
                for (int i = 0; i < count; i++)
                {
                    ViewTable key = array[i];
                    int       num = (int)this._inactiveViewTables[key];
                    if (--num > 0)
                    {
                        this._inactiveViewTables[key] = num;
                    }
                    else
                    {
                        this._inactiveViewTables.Remove(key);
                    }
                }
            }
            ArrayList arrayList = new ArrayList();
            bool      flag      = false;

            foreach (object obj in this)
            {
                DictionaryEntry  dictionaryEntry  = (DictionaryEntry)obj;
                WeakRefKey       weakRefKey       = (WeakRefKey)dictionaryEntry.Key;
                CollectionRecord collectionRecord = (CollectionRecord)dictionaryEntry.Value;
                if (weakRefKey.Target == null || !collectionRecord.IsAlive)
                {
                    arrayList.Add(weakRefKey);
                }
                else
                {
                    ViewTable viewTable = collectionRecord.ViewTable;
                    if (viewTable != null && viewTable.Purge())
                    {
                        flag = true;
                        if (viewTable.Count == 0)
                        {
                            collectionRecord.ViewTable = null;
                            if (!collectionRecord.IsAlive)
                            {
                                arrayList.Add(weakRefKey);
                            }
                        }
                    }
                }
            }
            for (int j = 0; j < arrayList.Count; j++)
            {
                base.Remove(arrayList[j]);
            }
            return(arrayList.Count > 0 || flag);
        }
Beispiel #2
0
        // purge the table of dead entries
        internal bool Purge()
        {
            // decrease the expiration dates of ViewTables on the inactive
            // list, and remove the ones that have expired.
            int n = _inactiveViewTables.Count;

            if (n > 0)
            {
                ViewTable[] keys = new ViewTable[n];
                _inactiveViewTables.Keys.CopyTo(keys, 0);

                for (int i = 0; i < n; ++i)
                {
                    ViewTable vt             = keys[i];
                    int       expirationDate = (int)_inactiveViewTables[vt];
                    if (--expirationDate > 0)
                    {
                        _inactiveViewTables[vt] = expirationDate;
                    }
                    else
                    {
                        _inactiveViewTables.Remove(vt);
                    }
                }
            }

            // purge the table of entries whose collection has been GC'd.
            ArrayList al = new ArrayList();
            bool      foundViewTableDirt = false;

            foreach (DictionaryEntry de in this)
            {
                WeakRefKey       key = (WeakRefKey)de.Key;
                CollectionRecord cr  = (CollectionRecord)de.Value;

                if (key.Target == null || !cr.IsAlive)
                {
                    al.Add(key);
                }
                else
                {
                    // also purge ViewTable entries whose key (CVS) has been GC'd
                    ViewTable vt = cr.ViewTable;
                    if (vt != null && vt.Purge())
                    {
                        foundViewTableDirt = true;
                        if (vt.Count == 0)
                        {
                            // remove the ViewTable (it has no views remaining)
                            cr.ViewTable = null;

                            if (!cr.IsAlive)
                            {
                                al.Add(key);
                            }
                        }
                    }
                }
            }

            for (int k = 0; k < al.Count; ++k)
            {
                this.Remove(al[k]);
            }

            return(al.Count > 0 || foundViewTableDirt);
        }