public static IEnumerable <ImmutableArrayInternal <T> > Create(int sourceIndex, T[] data, int length) { if (sourceIndex < 0) { throw new IndexOutOfRangeException("Index cannot be less than zero"); } if (data == null) { throw new ArgumentNullException("data", "Array cannot be null"); } if ((sourceIndex + length) > data.Length) { throw new ArgumentOutOfRangeException("The sourceIndex and length specified overcome the source ByteArray length"); } foreach (var buffer in _bufferManager.Allocate(length)) { var part = Math.Min(buffer.Length, length); Array.Copy(data, sourceIndex, buffer, 0, part); yield return(new ImmutableArrayInternal <T>(sourceIndex, buffer, part)); sourceIndex += part; length -= part; } }
public T[][] Allocate(int size) { lock (_bufferManager) { return(_bufferManager.Allocate(size)); } }
private void AllocAndFree(IBufferManager <byte> manager) { var alloc = Enumerable.Range(1, Allocations); Parallel.ForEach(alloc, (i) => { var buffer = manager.Allocate(BufferSize); manager.Free(buffer); }); }
private void AllocAndFree(IBufferManager <byte> manager) { var alloc = Enumerable.Range(1, Allocations).Select(i => manager.Allocate(BufferSize)).ToArray(); foreach (var a in alloc) { manager.Free(a); } }