// If the length returned is -1, then there's no more stream in the // master source, otherwise, buffer should be valid with the length returned // Note: This needs to be thread safe private FastStream GetNextSubStream(FastStream source) { lock (bufferLock) { if (source.EndOfStream) { return(null); } uint startLook = (uint)this.BufferSize * 3 / 4; uint length; bool isComplete; isComplete = this.TryGetCompleteBuffer(source, startLook, 1, source.MaxPeek - TruncateString.Length, out length); FastStream subStream = source.ReadSubStream((int)length, trail: (!isComplete ? TruncateString : null)); if (!isComplete) { this.FindValidStartOn(source); } source.SkipWhiteSpace(); return(subStream); } }