Solution: Write Code with Worker Pool and Generator Patterns
Check another solution to the challenge that uses the worker pool and generator patterns.
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 1300+ tech skills courses.