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