/// <summary> /// Ensures that the underlying id queue can hold at least a certain number of ids. /// </summary> /// <param name="count">Number of elements to preallocate space for in the available ids queue.</param> /// <param name="pool">Pool to pull resized spans from.</param> public void EnsureCapacity(int count, IUnmanagedMemoryPool pool) { if (!availableIds.Allocated) { //If this was disposed, we must explicitly rehydrate it. this = new IdPool(count, pool); } else { if (availableIds.Length < count) { InternalResize(count, pool); } } }
/// <summary> /// Resizes the underlying buffer to the smallest size required to hold the given count and the current available id count. /// </summary> /// <param name="count">Number of elements to guarantee space for in the available ids queue.</param> public void Resize(int count, IUnmanagedMemoryPool pool) { if (!availableIds.Allocated) { //If this was disposed, we must explicitly rehydrate it. this = new IdPool(count, pool); } else { var targetLength = BufferPool.GetCapacityForCount <int>(Math.Max(count, availableIdCount)); if (availableIds.Length != targetLength) { InternalResize(targetLength, pool); } } }