/// <summary> /// Initializes a new instance of the <see cref="LengthPrefixMessageFramerWithBufferPool"/> class. /// </summary> public LengthPrefixMessageFramerWithBufferPool(BufferManager bufferManager, int maxPackageSize = 16*1024*1024) { Ensure.NotNull(bufferManager, "bufferManager"); Ensure.Positive(maxPackageSize, "maxPackageSize"); _bufferManager = bufferManager; _maxPackageSize = maxPackageSize; }
/// <summary> /// Initializes a new instance of the <see cref="BufferPool"/> class. /// </summary> /// <param name="initialBufferCount">The number of initial buffers.</param> /// <param name="bufferManager">The buffer manager.</param> public BufferPool(int initialBufferCount, BufferManager bufferManager) { if (initialBufferCount <= 0) throw new ArgumentException("initialBufferCount"); if (bufferManager == null) throw new ArgumentNullException("bufferManager"); _length = 0; _buffers = new List<ArraySegment<byte>>(bufferManager.CheckOut(initialBufferCount)); // must have 1 buffer _chunkSize = _buffers[0].Count; _bufferManager = bufferManager; _disposed = false; }
/// <summary> /// Sets the default buffer manager. /// </summary> /// <param name="manager">The new default buffer manager.</param> public static void SetDefaultBufferManager(BufferManager manager) { if (manager == null) throw new ArgumentNullException("manager"); _defaultBufferManager = manager; }
/// <summary> /// Initializes a new instance of the <see cref="BufferPool"/> class. /// </summary> /// <param name="bufferManager">The buffer manager.</param> public BufferPool(BufferManager bufferManager) : this(1, bufferManager) { }