Ejemplo n.º 1
0
        private void TryFixPool()
        {
            int freeCacheCount = GetFreeCacheCount();
            int cacheCount     = GetCacheCount();

            if ((((float)cacheCount) / ((float)mCacheBlockMaxCount)) >= 0.9f)
            {
                if ((((float)freeCacheCount) / ((float)cacheCount)) < 0.2f)
                {
                    mCacheBlockMaxCount += 0x20;
                    if (mCacheBlockMaxCount > mBlockLimitCount)
                    {
                        mCacheBlockMaxCount = mBlockLimitCount;
                    }
                }
                else
                {
                    for (int i = 0; i < pool.Count; i++)
                    {
                        CachedObjectInfo info = pool[i];
                        int num4 = info.GetFreeCacheCount();
                        info.Shrink(num4 / 2);
                    }
                }
            }
        }
Ejemplo n.º 2
0
        public void ClearCache(object key)
        {
            CachedObjectInfo cacheInfo = GetCacheInfo(key);

            if (cacheInfo != null)
            {
                cacheInfo.Shrink(cacheInfo.GetFreeCacheCount());
            }
        }
Ejemplo n.º 3
0
        public int GetFreeCacheCount(object key)
        {
            CachedObjectInfo cacheInfo = GetCacheInfo(key);

            if (cacheInfo == null)
            {
                return(0);
            }
            return(cacheInfo.GetFreeCacheCount());
        }
Ejemplo n.º 4
0
        public void Update()
        {
            float realtimeSinceStartup = Time.realtimeSinceStartup;

            if ((realtimeSinceStartup - mLastUpdateTime) >= 5f)
            {
                mLastUpdateTime = realtimeSinceStartup;
                if (pool != null)
                {
                    int index = UnityEngine.Random.Range(0, pool.Count - 1);
                    if ((index >= 0) && (index < pool.Count))
                    {
                        CachedObjectInfo info = pool[index];
                        if (info == null)
                        {
                            pool.RemoveAt(index);
                        }
                        else
                        {
                            float num3           = Time.realtimeSinceStartup - info.GetWeight();
                            int   maxShrinkCount = (int)(num3 / 60f);
                            if (maxShrinkCount > 0)
                            {
                                int freeCacheCount = info.GetFreeCacheCount();
                                if (freeCacheCount <= 0)
                                {
                                    pool.RemoveAt(index);
                                }
                                else
                                {
                                    maxShrinkCount = (maxShrinkCount <= freeCacheCount) ? maxShrinkCount : freeCacheCount;
                                    info.Shrink(maxShrinkCount);
                                }
                            }
                        }
                    }
                }
            }
        }