Exemplo n.º 1
0
        public UnpooledArrayBuffer(IArrayBufferAllocator <T> allocator, T[] initialArray, int offset, int count)
            : base(count)
        {
            Contract.Requires(initialArray != null && initialArray.Length > 0);
            Contract.Requires(offset >= 0 && count > 0);
            Contract.Requires((offset + count) <= initialArray.Length);

            this.Allocator = allocator;
            this.Array     = initialArray;
            this.Offset    = offset;
            this.Count     = count;
        }
Exemplo n.º 2
0
        public UnpooledArrayBuffer(IArrayBufferAllocator <T> allocator, T[] initialArray,
                                   int readerIndex, int writerIndex, int maxCapacity)
            : base(maxCapacity)
        {
            Contract.Requires(allocator != null);
            Contract.Requires(initialArray != null);
            Contract.Requires(initialArray.Length <= maxCapacity);

            this.Allocator = allocator;
            this.SetArray(initialArray);
            this.SetIndex(readerIndex, writerIndex);
        }
Exemplo n.º 3
0
        protected AbstractByteBufferTests(bool pooled)
        {
            if (pooled)
            {
                this.allocator = new PooledArrayBufferAllocator <byte>();
            }
            else
            {
                this.allocator = new UnpooledArrayBufferAllocator <byte>();
            }

            this.random = new Random(Environment.TickCount);
        }
Exemplo n.º 4
0
        protected AbstractArrayBufferTest(bool pooled)
        {
            if (pooled)
            {
                this.allocator = new PooledArrayBufferAllocator <byte>();
            }
            else
            {
                this.allocator = new UnpooledArrayBufferAllocator <byte>();
            }

            this.buffer = this.allocator.Buffer(Capacity);
            this.seed   = Environment.TickCount;
            this.random = new Random(this.seed);
        }
Exemplo n.º 5
0
        public void Dispose()
        {
            if (this.buffer != null)
            {
                Assert.True(this.buffer.Release());
                Assert.Equal(0, this.buffer.ReferenceCount);

                try
                {
                    this.buffer.Release();
                }
                catch (Exception)
                {
                    // Ignore.
                }
                this.buffer = null;
            }

            this.allocator = null;
        }
Exemplo n.º 6
0
        internal EmptyArrayBuffer(IArrayBufferAllocator <T> allocator)
        {
            Contract.Requires(allocator != null);

            this.Allocator = allocator;
        }
Exemplo n.º 7
0
 public UnpooledArrayBuffer(IArrayBufferAllocator <T> allocator, T[] initialArray, int maxCapacity)
     : this(allocator, initialArray, 0, initialArray.Length, maxCapacity)
 {
 }
Exemplo n.º 8
0
 public UnpooledArrayBuffer(IArrayBufferAllocator <T> allocator, int initialCapacity, int maxCapacity)
     : this(allocator, new T[initialCapacity], 0, 0, maxCapacity)
 {
 }
Exemplo n.º 9
0
        internal ByteBufferAllocator(IArrayBufferAllocator <byte> arrayAllocator)
        {
            Contract.Requires(arrayAllocator != null);

            this.ArrayAllocator = arrayAllocator;
        }
Exemplo n.º 10
0
 public UnpooledArrayBuffer(IArrayBufferAllocator <T> allocator, T[] initialArray, int capacity)
     : this(allocator, initialArray, 0, capacity)
 {
 }