public T Take() { if (storage.Count == 0) { Allocate(); } return(storage.Take()); }
/// <summary> /// Returns pre-created array or creates new /// if there are any arrays free. /// </summary> private static T[] GetNextFreeArray(IStorageObject <T[]> storage, int size) { if (storage.Empty) { return(new T[size]); } // Get the array. var array = storage.Take(); Array.Clear(array, 0, array.Length); return(array); }
/// <summary> /// Takes next object from the pool. /// </summary> public T Take() => storage.Empty ? New() : storage.Take();