Skip to content

Commit 6a3b31d

Browse files
committed
review comments
1 parent 433ba41 commit 6a3b31d

3 files changed

Lines changed: 16 additions & 10 deletions

File tree

src/ColumnizerLib/ILogLine.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ public interface ILogLine : ITextValue
3939
/// </para>
4040
/// </remarks>
4141
public readonly struct LogLine (string fullLine, int lineNumber) : ILogLine
42+
{
4243
public string FullLine { get; } = fullLine;
4344

4445
public int LineNumber { get; } = lineNumber;

src/LogExpert.Benchmarks/StreamReaderBenchmarks.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -183,6 +183,6 @@ public static class Program
183183
{
184184
public static void Main (string[] args)
185185
{
186-
var summary = BenchmarkRunner.Run<StreamReaderBenchmarks>();
186+
_ = BenchmarkRunner.Run<StreamReaderBenchmarks>();
187187
}
188188
}

src/LogExpert.Core/Classes/Log/PositionAwareStreamReaderPipeline.cs

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -157,6 +157,7 @@ protected override void Dispose (bool disposing)
157157
{
158158
segment.Dispose();
159159
}
160+
160161
_lineQueue.Dispose();
161162
}
162163

@@ -200,6 +201,13 @@ private void RestartPipeline (long newPosition)
200201
}
201202
}
202203

204+
/// <summary>
205+
/// Cancels the current pipeline operation and releases associated resources. This method should be called while
206+
/// holding the appropriate lock to ensure thread safety.
207+
/// </summary>
208+
/// <remarks>This method cancels any ongoing producer task, marks the internal queue as complete to
209+
/// unblock waiting consumers, and disposes of pipeline resources. It is intended for internal use and must be
210+
/// invoked only when the pipeline is in a valid state for cancellation.</remarks>
203211
private void CancelPipelineLocked ()
204212
{
205213
if (_cts == null)
@@ -226,7 +234,7 @@ private void CancelPipelineLocked ()
226234
}
227235
finally
228236
{
229-
_cts?.Dispose();
237+
_cts.Dispose();
230238
_cts = null;
231239
}
232240

@@ -444,15 +452,12 @@ private void EnqueueLine (LineSegment segment)
444452
}
445453

446454
// If still no space, force process current content as truncated line
447-
if (charsInBuffer >= _charBufferSize - 100)
455+
if (charsInBuffer >= _charBufferSize - 100 && charsInBuffer > 0)
448456
{
449-
if (charsInBuffer > 0)
450-
{
451-
var segment = CreateSegment(charBuffer, 0, charsInBuffer, 0, byteOffset);
452-
byteOffset += segment.ByteLength;
453-
EnqueueLine(segment);
454-
charsInBuffer = 0;
455-
}
457+
var segment = CreateSegment(charBuffer, 0, charsInBuffer, 0, byteOffset);
458+
byteOffset += segment.ByteLength;
459+
EnqueueLine(segment);
460+
charsInBuffer = 0;
456461
}
457462

458463
charsAvailable = _charBufferSize - charsInBuffer;

0 commit comments

Comments
 (0)