Update Project

This commit is contained in:
2026-03-20 13:04:43 +02:00
parent 9b587e6cba
commit beae2dea89
2295 changed files with 251259 additions and 33 deletions
@@ -0,0 +1,54 @@
using System.Collections.Generic;
namespace Zenject
{
public class ArrayPool<T> : StaticMemoryPoolBaseBase<T[]>
{
readonly int _length;
public ArrayPool(int length)
: base(OnDespawned)
{
_length = length;
}
static void OnDespawned(T[] arr)
{
for (int i = 0; i < arr.Length; i++)
{
arr[i] = default(T);
}
}
public T[] Spawn()
{
#if ZEN_MULTITHREADING
lock (_locker)
#endif
{
return SpawnInternal();
}
}
protected override T[] Alloc()
{
return new T[_length];
}
static readonly Dictionary<int, ArrayPool<T>> _pools =
new Dictionary<int, ArrayPool<T>>();
public static ArrayPool<T> GetPool(int length)
{
ArrayPool<T> pool;
if (!_pools.TryGetValue(length, out pool))
{
pool = new ArrayPool<T>(length);
_pools.Add(length, pool);
}
return pool;
}
}
}