using System; using System.Collections.Generic; namespace DotRecast.Core.Buffers { // This implementation is thread unsafe public class RcObjectPool where T : class { private readonly Queue _items = new Queue(); private readonly Func _createFunc; public RcObjectPool(Func createFunc) { _createFunc = createFunc; } public T Get() { if (_items.TryDequeue(out var result)) return result; return _createFunc(); } public void Return(T obj) { _items.Enqueue(obj); } } }