Exemple #1
0
        public T Take()
        {
            if (storage.Count == 0)
            {
                Allocate();
            }

            return(storage.Take());
        }
Exemple #2
0
        /// <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);
        }
Exemple #3
0
 /// <summary>
 /// Takes next object from the pool.
 /// </summary>
 public T Take()
 => storage.Empty ? New() : storage.Take();