The concept of a coroutine sounds very interesting, but I don\'t know, if it makes sense in a real productive environment? What are use-cases for coroutines, that can be solved
Lots of them, for example:
grep TODO *.c *.h | wc -l
The pipeline above is exactly a coroutine: the grep
command generates a sequence of lines which go to a buffer, the wc
command "eats them up"; if the buffer fills, the grep
"blocks" until the buffer empties, and if the buffer is empty, the wc
command waits for new input.
The thing about coroutines is that they are most often now used either in more constrained patterns, like the Python generators mentioned, or as pipelines.
If you want to look more at them, see the Wikipedia articles, especially on coroutines and iterators.