예제 #1
0
        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);
        }
예제 #2
0
 public static OwnedBuffer <T> Create(T[] array)
 {
     if (Pool.TryTake(out OwnedPooledArray <T> pooled))
     {
         var asOwnedPooledArray = pooled;
         // ReSharper disable once PossibleNullReferenceException
         asOwnedPooledArray.Initialize(array, 0, array.Length);
         return(asOwnedPooledArray);
     }
     return(new OwnedPooledArray <T>(array));
 }
예제 #3
0
        internal static TImpl Create(IMutableSeries <TKey, TValue> innerSeries)
        {
            TImpl inner;

            if (!Pool.TryTake(out inner))
            {
                inner = new TImpl();
            }
            inner.Inner = innerSeries;
            return(inner);
        }