public T GetItem() { ObjectPoolContainer <T> container = null; for (int i = 0; i < list.Count; i++) { lastIndex++; if (lastIndex > list.Count - 1) { lastIndex = 0; } if (list[lastIndex].Used) { continue; } else { container = list[lastIndex]; break; } } if (container == null) { container = CreateConatiner(); } container.Consume(); lookup.Add(container.Item, container); return(container.Item); }
private ObjectPoolContainer <T> CreateConatiner() { var container = new ObjectPoolContainer <T>(); container.Item = factoryFunc(); list.Add(container); return(container); }