示例#1
0
        internal GatherStream(byte[] buffer, BlockMap assignedBlocks, TimeSpan timeout) : base(buffer, false)
        {
            if (assignedBlocks == null)
            {
                throw new ArgumentNullException(nameof(assignedBlocks));
            }

            this.assignedBlocks = assignedBlocks;
            this.timeout        = timeout;
        }
示例#2
0
        internal GatherStream(byte[] buffer, BlockMap assignedBlocks, TimeSpan timeout) : base(buffer, false)
        {
            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));
            }

            this.assignedBlocks = assignedBlocks;
            this.timeout        = timeout;
        }
示例#3
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);
        }
示例#4
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);
            }
        }