Grokking Concurrency in Go
Vote

0% completed

​

Draining Work Before Exit

The program below runs the same worker pool twice. Each time, two workers take jobs from a queue of six, every job takes 100 ms, and shutdown is requested at 150 ms. The only difference is how the shutdown is requested. The first run cancels the workers' context; the second closes the jobs channel and lets the workers continue.

Output:

cancel: 2 done, 2 interrupted, 2 never started, 150ms close : 6 done, 0 interrupted, 0 never started, 300ms

Canceling stopped everything at 150 ms, and four of the six jobs were not completed

.....

.....

.....

Like the course? Get enrolled and start learning!

Reading Progress

0%


Vote for new content