Exemple #1
0
        public T[] CheckOut(int size)
        {
            var logSize = BufferPoolUtils.Log2(size);

            if ((1 << logSize) < size)
            {
                throw new Exception("TLBP Exception !!!!!!!!!");
            }

            if (logSize < stacks.Length && stacks[logSize].Count > 0)
            {
                return(stacks[logSize].Pop());
            }
            else
            {
                try
                {
                    T[] res = new T[1 << logSize];
                    return(res);
                }
                catch (Exception e)
                {
                    Debug.Assert(false);
                    Logging.Fatal("BufferPool.CheckOut exception {0}", e);
                    Logging.Fatal("Size {0}, Type {1}", logSize, typeof(T));
                    Logging.Fatal(e.StackTrace);
                    throw new FatalException();
                }
            }
        }
Exemple #2
0
        public T[] CheckOutInitialized(int size)
        {
            size = BufferPoolUtils.Log2(size);

            if (size < stacks.Length && stacks[size].Count > 0)
            {
                var array = stacks[size].Pop();

                Array.Clear(array, 0, array.Length);

                return(array);
            }
            else
            {
                return(new T[1 << size]);
            }
        }