Example #1
0
        private void Start()
        {
            #region SimpleObjectPool
            var pool = new SimpleObjectPool <Fish>(() => new Fish(), initCount: 50);

            pool.CurCount.LogInfo();

            var fish = pool.Allocate();

            pool.CurCount.LogInfo();

            pool.Recycle(fish);

            pool.CurCount.LogInfo();
            #endregion



            #region SafeObjectPool

            SafeObjectPool <Bullet> .Instance.Init(50, 25);

            var bullet = Bullet.Allocate();

            SafeObjectPool <Bullet> .Instance.CurCount.LogInfo();

            bullet.Recycle2Cache();

            SafeObjectPool <Bullet> .Instance.CurCount.LogInfo();

            #endregion
        }