internal ScatterStream(byte[] buffer, BlockMap assignedBlocks, TimeSpan timeout) : base(buffer) { if (assignedBlocks == null) { throw new ArgumentNullException(nameof(assignedBlocks)); } if (buffer.Length != assignedBlocks.Capacity) { throw new ArgumentException($"{nameof(assignedBlocks)} capacity does not match {nameof(buffer)} length".ToString(CultureInfo.CurrentCulture)); } _assignedBlocks = assignedBlocks; _timeout = timeout; }
public static void CreateScatterGatherStreams(int capacity, TimeSpan timeout, out Stream scatterStream, out Stream gatherStream) { if (capacity <= 0) { throw new ArgumentOutOfRangeException(nameof(capacity), $"{nameof(capacity)} must be positive.".ToString(CultureInfo.CurrentCulture)); } if (timeout < _defaultTimeout) { throw new ArgumentOutOfRangeException(nameof(timeout), $"{nameof(timeout)} must be greater than {_defaultTimeout:c}.".ToString(CultureInfo.CurrentCulture)); } var buffer = new byte[capacity]; var assignedBlocks = new BlockMap(capacity); scatterStream = new ScatterStream(buffer, assignedBlocks, timeout); gatherStream = new GatherStream(buffer, assignedBlocks, timeout); }
public static void CreateScatterGatherStreams(int capacity, TimeSpan timeout, out Stream scatterStream, Stream[] gatherStreams) { if (capacity <= 0) { throw new ArgumentOutOfRangeException(nameof(capacity), $"{nameof(capacity)} must be positive.".ToString(CultureInfo.CurrentCulture)); } if (timeout < _defaultTimeout) { throw new ArgumentOutOfRangeException(nameof(timeout), $"{nameof(timeout)} must be greater than {_defaultTimeout:c}.".ToString(CultureInfo.CurrentCulture)); } if (gatherStreams == null) { throw new ArgumentNullException(nameof(gatherStreams)); } var buffer = new byte[capacity]; var assignedBlocks = new BlockMap(capacity); scatterStream = new ScatterStream(buffer, assignedBlocks, timeout); foreach (var i in Enumerable.Range(0, gatherStreams.Length)) { gatherStreams[i] = new GatherStream(buffer, assignedBlocks, timeout); } }