Read data from the incoming channel, process it, then send it on the outgoing channel
| 23 | |
| 24 | // Read data from the incoming channel, process it, then send it on the outgoing channel |
| 25 | void transform(chan& incoming, chan& outgoing) |
| 26 | { |
| 27 | for (auto input : incoming) { |
| 28 | auto result = add(input, 2); |
| 29 | outgoing << result; |
| 30 | } |
| 31 | } |
| 32 | |
| 33 | // Read result of processing from the outgoing channel and save it |
| 34 | void write_outgoing(chan& outgoing) |