You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardexpand all lines: README.md
+13-7
Original file line number
Diff line number
Diff line change
@@ -5,9 +5,10 @@
5
5
This library helps at building simple [TPL Dataflow](https://docs.microsoft.com/en-us/dotnet/standard/parallel-programming/dataflow-task-parallel-library) pipelines,
6
6
that enforce the following guarantees:
7
7
8
-
1. In case any constituent block fails, all other blocks will complete as soon as possible.
8
+
1. In case any constituent dataflow block fails, all the other blocks will complete
9
+
as soon as possible.
9
10
2. When a pipeline as a whole completes either successfully or with an error, all of its
10
-
constituent blocks will be also completed.
11
+
constituent dataflow blocks will be also completed.
11
12
3. The [`Completion`](https://docs.microsoft.com/en-us/dotnet/api/system.threading.tasks.dataflow.idataflowblock.completion)
12
13
of the pipeline propagates all errors that may have occurred in all blocks,
13
14
accumulated inside a flat [`AggregateException`](https://docs.microsoft.com/en-us/dotnet/api/system.aggregateexception).
@@ -19,22 +20,25 @@ provides a deeper insight about why this library exists.
19
20
The problem with building pipelines using the traditional [`LinkTo`](https://docs.microsoft.com/en-us/dotnet/api/system.threading.tasks.dataflow.dataflowblock.linkto) method,
20
21
configured with the [`PropagateCompletion`](https://docs.microsoft.com/en-us/dotnet/api/system.threading.tasks.dataflow.dataflowlinkoptions.propagatecompletion) option,
21
22
is that it allows the possibility of deadlocks and leaked
22
-
active fire-and-forget blocks:
23
+
fire-and-forget dataflow blocks:
23
24
24
25
1. A deadlock can occur in case a producer is blocked, waiting
25
-
for empty space in the input buffer of the first block of a bounded pipeline, and any other
26
+
for empty space in the input buffer of the first dataflow block of a bounded pipeline, and any other
26
27
block except from the first one fails. In this case the producer will never be unblocked,
27
28
because the first block will postpone all incoming messages ad infinitum, never accepting
28
29
or declining any offered message.
29
30
30
31
2. A leaked fire-and-forget block can occur under similar
31
-
circumstances. When any but the first block fails, the error will be propagated
32
+
circumstances. When any but the first dataflow block fails, the error will be propagated
32
33
downstream but not upstream. So the pipeline will soon signal its completion, while
33
34
some blocks near the top may still be in a running state. These blocks will be leaked as
34
35
fire-and-forget blocks, consuming resources and potentialy modifying the state of the
35
36
application in unpredictable ways. Or they can just get stuck and become the source of a
36
37
deadlock, as described previously.
37
38
39
+
3. The standard approach for propagating errors, the `PropagateCompletion` option,
40
+
results to deeply nested [`AggregateException`](https://docs.microsoft.com/en-us/dotnet/api/system.aggregateexception)s.
41
+
38
42
This library attempts to fix these problems.
39
43
40
44
## How to make a pipeline
@@ -80,7 +84,7 @@ Whether it can emit messages depends on the type of the last block added in the
80
84
81
85
When the pipeline is created, all the blocks are linked automatically with the built-in [`LinkTo`](https://docs.microsoft.com/en-us/dotnet/api/system.threading.tasks.dataflow.dataflowblock.linkto) method,
82
86
configured with the [`PropagateCompletion`](https://docs.microsoft.com/en-us/dotnet/api/system.threading.tasks.dataflow.dataflowlinkoptions.propagatecompletion) option set to `false`.
83
-
Then a continuation is attached to the completion of each block, that takes an appropriate
87
+
Then a continuation is attached to the `Completion` of each block, that takes an appropriate
84
88
action depending on how the block was completed. If the block was completed successfully or
85
89
it was canceled, the completion is propagated to the next block by invoking the next block's
0 commit comments