Ejemplo n.º 1
0
        /// <summary>
        /// Initializes a new instance of the <see cref="Buffer{T}"/> class.
        /// </summary>
        /// <param name="length">The desired count of elements. (Minimum size for <see cref="Array"/>)</param>
        public Buffer(int length)
        {
            this.Length = length;
            this.Array  = PixelDataPool <T> .Rent(length);

            this.isPoolingOwner = true;
        }
Ejemplo n.º 2
0
        public void Dispose()
        {
            if (this.IsDisposedOrLostArrayOwnership)
            {
                return;
            }

            this.IsDisposedOrLostArrayOwnership = true;
            this.UnPin();

            if (this.isPoolingOwner)
            {
                PixelDataPool <T> .Return(this.Array);
            }

            this.isPoolingOwner = false;
            this.Array          = null;
            this.Length         = 0;

            GC.SuppressFinalize(this);
        }