File tree Expand file tree Collapse file tree 1 file changed +11
-6
lines changed
Expand file tree Collapse file tree 1 file changed +11
-6
lines changed Original file line number Diff line number Diff line change @@ -19,10 +19,10 @@ A set of extensions for optimizing/simplifying System.Threading.Channels usage.
1919
2020### Special ` ChannelReader ` Operations
2121
22- * ` Filter `
23- * ` Transform `
24- * ` Batch `
25- * ` Join `
22+ * ` Filter ` : reads from the channel until a match is found.
23+ * ` Transform ` : applies a transform function upon successfully reading an item from the channel.
24+ * ` Batch ` : attempts to group items into a ` List<T> ` (or a ` Queue<T> ` ) before being available for reading.
25+ * ` Join ` : combines batches into a single channel.
2626
2727---
2828## Installation
@@ -127,6 +127,9 @@ await channel.WriteAllConcurrentlyAsync(
127127
128128### Filter & Transform
129129
130+ Both of these extensions operate synchronously after an item is read from the channel.
131+ > Any predicate or selector function must trap errors of the downstream read will fail and data may not be recoverable.
132+
130133``` cs
131134// Filter and transform when reading.
132135channel .Reader
@@ -139,16 +142,18 @@ channel.Reader
139142
140143``` cs
141144values .Reader
142- .Batch (10 /* batch size*/ )
145+ .Batch (10 /* batch size*/ ) // Groups into List<T>.
143146 .WithTimeout (1000 ) // Any non-empty batches are flushed every second.
144147 .ReadAllAsync (async batch => {/* ...*/ });
145148```
146149
147150### Joining
148151
152+ The inverse of batching.
153+
149154``` cs
150155batches .Reader
151- .Join ()
156+ .Join () // Combines the batches into a single channel.
152157 .ReadAllAsync (async value => {/* ...*/ });
153158```
154159
You can’t perform that action at this time.
0 commit comments