Generator Pattern

Let's study our first pattern​ of concurrency, which is about generators that return channels as returning argument.

In this chapter, we’ll look at some concurrency patterns that can come in handy while we write concurrent code.

Let’s begin with generators. Generators return the next value in a sequence each time they are called. This means that each value is available as an output before the generator computes the next value. Hence, this pattern is used to introduce parallelism in our program.

Have a look at the simple example below:

Get hands-on with 1200+ tech skills courses.