音频内容

This commit is contained in:
2024-09-19 01:12:10 +08:00
parent 1c390954ce
commit 35bd460011
80 changed files with 2205 additions and 59 deletions
@@ -0,0 +1,33 @@
/*
* 普通对象池
*/
using System;
namespace AibisDream.Kit
{
public class SimpleObjectPool<T> : Pool<T>
{
readonly Action<T> mResetMethod;
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());
}
}
public override bool Recycle(T obj)
{
mResetMethod?.Invoke(obj);
mCacheStack.Push(obj);
return true;
}
}
}