Ejemplo n.º 1
0
 public void Dispose()
 {
     if (_pin == null)
     {
         return;
     }
     _pin.Dispose();
     _pin = null;
 }
Ejemplo n.º 2
0
        private BytePool()
        {
            var extraSmallPointers = Enumerable.Range(0, 1024).Select(e => e * 256).ToArray();
            int offset             = extraSmallPointers.Last() + 256;
            var smallPointers      = Enumerable.Range(0, 1024).Select(e => (e * 512) + offset).ToArray();

            offset = smallPointers.Last() + 512;
            var mediumPointers = Enumerable.Range(0, 1024).Select(e => (e * 1024) + offset).ToArray();

            offset = mediumPointers.Last() + 1024;
            var largePointers = Enumerable.Range(0, 1024).Select(e => (e * 2048) + offset).ToArray();
            int size          = largePointers.Last() + 2048;

            _pin = new BufferPin(size);

            _extraSmallPointers = new ConcurrentStack <int>(extraSmallPointers);
            _smallPointers      = new ConcurrentStack <int>(smallPointers);
            _mediumPointers     = new ConcurrentStack <int>(mediumPointers);
            _largePointers      = new ConcurrentStack <int>(largePointers);
        }