public static OwnedMemory <T> Create(T[] array) { if (!Pool.TryTake(out OwnedPooledArray <T> ownedPooledArray)) { ownedPooledArray = new OwnedPooledArray <T>(); } ownedPooledArray._array = array; ownedPooledArray._disposed = false; ownedPooledArray._referenceCount = 0; return(ownedPooledArray); }
public static OwnedMemory <T> Create(int size) { if (!Pool.TryTake(out OwnedPooledArray <T> ownedPooledArray)) { ownedPooledArray = new OwnedPooledArray <T>(); } ownedPooledArray._array = BufferPool <T> .Rent(size, false); ownedPooledArray._disposed = false; ownedPooledArray._referenceCount = 0; return(ownedPooledArray); }
internal static OwnedMemory <T> RentOwnedBuffer(int minLength, bool requireExact = true) { var array = Rent(minLength, requireExact); return(OwnedPooledArray <T> .Create(array)); }