Beispiel #1
0
 public SimpleObjectPool(Func <T> factoryMethod, Action <T> resetMethod = null, int initCount = 0)
 {
     MFactory      = new CustomObjectFactory <T>(factoryMethod);
     _mResetMethod = resetMethod;
     for (var i = 0; i < initCount; i++)
     {
         MCacheStack.Push(MFactory.Create());
     }
 }
Beispiel #2
0
        public override bool Recycle(T obj)
        {
            if (_mResetMethod != null)
            {
                _mResetMethod(obj);
            }

            MCacheStack.Push(obj);
            return(true);
        }