Exemple #1
0
        public async Task TestArrayPoolAsync()
        {
            AssertError <ArgumentOutOfRangeException>(() => _ = new FixedSizeArrayPool <byte>(-3));

            var arrayPool = new FixedSizeArrayPool <byte>(500);

            AssertEqual(0, arrayPool.Count);

            var item = arrayPool.Rent();

            AssertEqual(true, item.IsPinned);
            AssertEqual(0, arrayPool.Count);
            AssertEqual(500, item.GetData().Length);

            await item.UnPin().NoSync();

            AssertEqual(false, item.IsPinned);
            AssertEqual(1, arrayPool.Count);
        }
Exemple #2
0
 /// <summary>
 ///     create a new page
 /// </summary>
 /// <param name="number">page number</param>
 /// <param name="owner">buffer owner</param>
 /// <param name="buffer">data buffer</param>
 internal Page(long number, BufferBase owner, FixedSizeArrayPool <byte> buffer)
 {
     Number = number;
     Owner  = owner;
     Buffer = buffer.Rent();
 }