示例#1
0
 internal IOOperation(GlobalThrottledStream stream, byte[] buffer, int offset, int count, bool isWriteOp)
 {
     this.stream    = stream;
     this.buffer    = buffer;
     this.offset    = offset;
     this.count     = count;
     this.isWriteOp = isWriteOp;
 }
示例#2
0
            internal static void ThrottledWrite(GlobalThrottledStream stream, byte[] buffer, int offset, int count)
            {
                long bytesPerSecond = GetBytesPerSecond(stream.ruleSetId);

                if (bytesPerSecond == 0)
                {
                    stream.originalStream.Write(buffer, offset, count);
                    return;
                }
                IOOperation       ioop    = new IOOperation(stream, buffer, offset, count, true);
                ThrottlingRuleSet ruleSet = ruleSets[stream.ruleSetId];

                ruleSet.PerformBlockingIOOperation(ioop);
            }
示例#3
0
            internal static int ThrottledRead(GlobalThrottledStream stream, byte[] buffer, int offset, int count)
            {
                long bytesPerSecond = GetBytesPerSecond(stream.ruleSetId);

                if (bytesPerSecond == 0)
                {
                    return(stream.originalStream.Read(buffer, offset, count));
                }

                IOOperation       ioop    = new IOOperation(stream, buffer, offset, count, false);
                ThrottlingRuleSet ruleSet = ruleSets[stream.ruleSetId];

                return(ruleSet.PerformBlockingIOOperation(ioop));
            }