Grokking Concurrency in Go
Vote

0% completed

​

Backpressure and Bounded Queues

The program below runs the same producer and the same consumer twice. The producer has 20 jobs ready and sends them as fast as the queue accepts them. The consumer finishes one job every 10 ms, so it handles 100 jobs per second. The only difference between the two runs is the capacity of the channel between them: 1,000 in the first run and 5 in the second.

Output:

capacity 1000: producer finished after 0s capacity 1000: consumer finished after 200ms capacity 5: producer finished after 140ms capacity 5: consumer finished after 200ms

.....

.....

.....

Like the course? Get enrolled and start learning!

Reading Progress

0%


Vote for new content