Skip to content

Commit 3d3c1f5

Browse files
OK
1 parent f6c295c commit 3d3c1f5

File tree

1 file changed

+23
-25
lines changed

1 file changed

+23
-25
lines changed

src/SimpleTplDataflowPipelines/PipelineBuilder.cs

+23-25
Original file line numberDiff line numberDiff line change
@@ -97,9 +97,9 @@ public PipelineBuilder<TInput, TNewOutput> LinkTo<TNewOutput>(
9797
{
9898
if (block == null) throw new ArgumentNullException(nameof(block));
9999
var source = _source;
100-
var action = new LinkDelegate(completions
101-
=> PipelineCommon.LinkTo(source, block, completions));
102-
var newActions = PipelineUtilities.Append(_linkDelegates, action);
100+
var action = new LinkDelegate(
101+
completions => PipelineCommon.LinkTo(source, block, completions));
102+
var newActions = PipelineCommon.Append(_linkDelegates, action);
103103
return new PipelineBuilder<TInput, TNewOutput>(_target, block, newActions);
104104
}
105105

@@ -112,9 +112,9 @@ public PipelineBuilder<TInput> LinkTo(ITargetBlock<TOutput> block)
112112
{
113113
if (block == null) throw new ArgumentNullException(nameof(block));
114114
var source = _source;
115-
var action = new LinkDelegate(completions
116-
=> PipelineCommon.LinkTo(source, block, completions));
117-
var newActions = PipelineUtilities.Append(_linkDelegates, action);
115+
var action = new LinkDelegate(
116+
completions => PipelineCommon.LinkTo(source, block, completions));
117+
var newActions = PipelineCommon.Append(_linkDelegates, action);
118118
return new PipelineBuilder<TInput>(_target, newActions);
119119
}
120120

@@ -176,6 +176,7 @@ internal static void LinkTo<TOutput>(
176176
// internally by the TPL Dataflow library. The ContinueWith method is used for
177177
// creating fire-and-forget continuations, with any error thown inside the
178178
// continuations propagated to the ThreadPool.
179+
// https://source.dot.net/System.Threading.Tasks.Dataflow/Internal/Common.cs.html#7160be0ba468d387
179180
// It's extremely unlikely that any of these continuations will ever fail since,
180181
// according to the documentation, the invoked APIs do not throw exceptions.
181182

@@ -207,6 +208,22 @@ internal static void OnErrorThrowOnThreadPool(Action action)
207208
ThreadPool.QueueUserWorkItem(state => { ((ExceptionDispatchInfo)state).Throw(); }, edi);
208209
}
209210
}
211+
212+
internal static T[] Append<T>(T[] array, T item)
213+
{
214+
T[] newArray;
215+
if (array == null || array.Length == 0)
216+
{
217+
newArray = new T[1];
218+
}
219+
else
220+
{
221+
newArray = new T[array.Length + 1];
222+
Array.Copy(array, newArray, array.Length);
223+
}
224+
newArray[newArray.Length - 1] = item;
225+
return newArray;
226+
}
210227
}
211228

212229
internal class Pipeline<TInput> : ITargetBlock<TInput>
@@ -282,23 +299,4 @@ public bool TryReceiveAll(out IList<TOutput> items)
282299
return false;
283300
}
284301
}
285-
286-
internal static class PipelineUtilities
287-
{
288-
internal static T[] Append<T>(T[] array, T item)
289-
{
290-
T[] newArray;
291-
if (array == null || array.Length == 0)
292-
{
293-
newArray = new T[1];
294-
}
295-
else
296-
{
297-
newArray = new T[array.Length + 1];
298-
Array.Copy(array, newArray, array.Length);
299-
}
300-
newArray[newArray.Length - 1] = item;
301-
return newArray;
302-
}
303-
}
304302
}

0 commit comments

Comments
 (0)