/* * 普通对象池 */ using System; namespace AibisDream.Kit { public class SimpleObjectPool : Pool { readonly Action mResetMethod; public SimpleObjectPool(Func factoryMethod, Action resetMethod = null, int initCount = 0) { mFactory = new CustomObjectFactory(factoryMethod); mResetMethod = resetMethod; for (var i = 0; i < initCount; i++) { mCacheStack.Push(mFactory.Create()); } } public override bool Recycle(T obj) { mResetMethod?.Invoke(obj); mCacheStack.Push(obj); return true; } } }