public void ReturnPoolItem(T item) { PooleableObject <T> poolObject = null; if (0 < this.unusedQueue.Count) { poolObject = this.unusedQueue.Dequeue(); poolObject.item = item; } else { poolObject = new PooleableObject <T>(item); } this.itemQueue.Enqueue(poolObject); }
public T GetPoolItem() { T item = default; if (0 < this.itemQueue.Count) { PooleableObject <T> poolObject = this.itemQueue.Dequeue(); this.unusedQueue.Enqueue(poolObject); item = poolObject.item; } else { item = this.Create(); } return(item); }