Solution: Write Code with Worker Pool and Generator Patterns
Check another solution to the challenge that uses the worker pool and generator patterns.
We'll cover the following
Problem breakdown
Since we already know the generator pattern, let’s add it to the following functions. Using the generator pattern in this way will return the channel.
For allocate
, the function’s definition will take the numberOfJobs
as input. The allocate
function will return a channel of type Job
. Within the function, we loop over the numberofJobs
and pass the values into the channel.
Get hands-on with 1400+ tech skills courses.