public void Get_whenSameThread_samePoolInstance()
        {
            var pool1 = _bufferPoolThreadLocal.Get();
            var pool2 = _bufferPoolThreadLocal.Get();

            Assert.AreSame(pool1, pool2);
        }
Exemplo n.º 2
0
        static void WriteALotOfBytes(BufferPoolThreadLocal local)
        {
            var pool   = local.Get();
            var buffer = pool.TakeOutputBuffer();

            buffer.WriteBytes(ALotOfBytes);
            pool.ReturnOutputBuffer(buffer);
        }
        public void Get_whenDifferentThreadLocals_thenDifferentInstances()
        {
            var bufferPoolThreadLocal2 = new BufferPoolThreadLocal(_serializationService);

            var pool1 = _bufferPoolThreadLocal.Get();
            var pool2 = bufferPoolThreadLocal2.Get();

            Assert.AreNotSame(pool1, pool2);
        }