public 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.");
            if (timeout < defaultTimeout)
                throw new ArgumentOutOfRangeException(nameof(timeout), $"{nameof(timeout)} must be greater than {defaultTimeout:c}.");

            var buffer = new byte[capacity];
            var assignedBlocks = new BlockMap(capacity);
            scatterStream = new ScatterStream(buffer, assignedBlocks, timeout);
            gatherStream = new GatherStream(buffer, assignedBlocks, timeout);
        }
Ejemplo n.º 2
0
        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);
        }
Ejemplo n.º 3
0
        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);
            }
        }