コード例 #1
0
ファイル: OwnedPooledArray.cs プロジェクト: lulzzz/Spreads
 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);
 }
コード例 #2
0
ファイル: OwnedPooledArray.cs プロジェクト: lulzzz/Spreads
        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);
        }
コード例 #3
0
        internal static OwnedMemory <T> RentOwnedBuffer(int minLength, bool requireExact = true)
        {
            var array = Rent(minLength, requireExact);

            return(OwnedPooledArray <T> .Create(array));
        }