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); } }