diff --git a/Source/Channel/ChannelPump.cs b/Source/Channel/ChannelPump.cs index 3f8cf42c..fec60665 100644 --- a/Source/Channel/ChannelPump.cs +++ b/Source/Channel/ChannelPump.cs @@ -18,17 +18,12 @@ internal static class ChannelPump /// to complete the writer when the pass ends, /// with the exception that ended it if there was one. /// - /// - /// to wait for room before the feed starts, - /// so a full target never gets a command run or a connection opened for it. - /// /// Stops the pass. /// The number of rows handed to the writer. internal static async ValueTask Run( TFeed feed, ChannelWriter writer, bool complete, - bool waitFirst, CancellationToken cancellationToken) where TFeed : struct, IFeed { @@ -39,11 +34,12 @@ internal static async ValueTask Run( Exception? error = null; try { + // Wait for room before the feed starts, so a full target never + // gets a command run or a connection opened for it. // Closed before the first row: nothing to write, nothing read. - if (waitFirst - && !await writer - .WaitToWriteAsync(cancellationToken) - .ConfigureAwait(false)) + if (!await writer + .WaitToWriteAsync(cancellationToken) + .ConfigureAwait(false)) { return 0; } diff --git a/Source/Channel/ToChannel.Produce.cs b/Source/Channel/ToChannel.Produce.cs index c4de9b69..446cf667 100644 --- a/Source/Channel/ToChannel.Produce.cs +++ b/Source/Channel/ToChannel.Produce.cs @@ -223,7 +223,6 @@ IAsyncEnumerable> chunks AllowSynchronousContinuations = false, }); - // The channel is empty: there is room, so the first wait is skipped. // A failure reaches the channel through Complete; the task // is dropped unobserved unless the caller asked for the count. readCount = ChannelPump @@ -231,7 +230,6 @@ IAsyncEnumerable> chunks new(chunks), channel.Writer, complete: true, - waitFirst: false, cancellationToken) .AsTask(); diff --git a/Source/Channel/ToChannel.Streaming.cs b/Source/Channel/ToChannel.Streaming.cs index 2e5c8790..c9560ad2 100644 --- a/Source/Channel/ToChannel.Streaming.cs +++ b/Source/Channel/ToChannel.Streaming.cs @@ -132,7 +132,6 @@ public static ValueTask ToChannelHoldingConnection( new(source.StreamBuffered(stallTimeout, 1, cancellationToken)), writer, complete, - waitFirst: true, cancellationToken); } diff --git a/Source/Channel/ToChannel.Target.cs b/Source/Channel/ToChannel.Target.cs index 9362634d..3e14b9ed 100644 --- a/Source/Channel/ToChannel.Target.cs +++ b/Source/Channel/ToChannel.Target.cs @@ -122,7 +122,6 @@ public static ValueTask ToChannel( new(source.ToPooledBufferStream(cancellationToken)), writer, complete, - waitFirst: true, cancellationToken); } diff --git a/Source/Dataflow/BlockPump.cs b/Source/Dataflow/BlockPump.cs index ca134c36..08cecd66 100644 --- a/Source/Dataflow/BlockPump.cs +++ b/Source/Dataflow/BlockPump.cs @@ -20,17 +20,12 @@ internal static class BlockPump /// to complete the target when the pass ends, /// or to fault it with the exception that ended the pass. /// - /// - /// to stop before the feed starts when the - /// target is already finished, so no command is run for it. - /// /// Stops the pass. /// The number of rows the target accepted. internal static async ValueTask Run( TFeed feed, ITargetBlock target, bool complete, - bool checkOpen, CancellationToken cancellationToken) where TFeed : struct, IFeed { @@ -42,8 +37,9 @@ internal static async ValueTask Run( try { // A block has no way to ask for room: only a row can tell. - // A block that is already finished is the one thing known now. - if (checkOpen && target.Completion.IsCompleted) + // A block that is already finished is the one thing known now, + // and no command is run for it. + if (target.Completion.IsCompleted) return 0; return await feed diff --git a/Source/Dataflow/DataflowExtensions.cs b/Source/Dataflow/DataflowExtensions.cs index 0b30491a..9048c202 100644 --- a/Source/Dataflow/DataflowExtensions.cs +++ b/Source/Dataflow/DataflowExtensions.cs @@ -93,7 +93,6 @@ IAsyncEnumerable> chunks new(chunks), block, complete: true, - checkOpen: false, cancellationToken) .AsTask() .ContinueWith( @@ -191,7 +190,6 @@ public static ValueTask ToTargetBlock( new(source.ToPooledBufferStream(cancellationToken)), target, complete, - checkOpen: true, cancellationToken); } @@ -289,7 +287,6 @@ public static ValueTask ToTargetBlockHoldingConnection( new(source.StreamBuffered(stallTimeout, 1, cancellationToken)), target, complete, - checkOpen: true, cancellationToken); }