public void Dispose() { if (_pin == null) { return; } _pin.Dispose(); _pin = null; }
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); }