O'Reilly logo

Distributed Computing with Go by V.N. Nikhil Anurag

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Distributed work without channels

In order to distribute the work equally among the cashiers, we need to know the amount of orders we will get beforehand and ensure that the work each cashier receives is within his/her limit. This is not the most practical solution, because it would fail in a real-world scenario where we would need to keep track of how many orders each cashier has processed and divert the remaining orders to the other cashiers. However, before we look at the correct way to solve it, let's take time to better understand the problem of uncontrolled parallelism and try to solve it. The following code attempts to solve it in a naïve manner, which should provide us with a good start:

// wochan.go package main import ( "fmt" "sync" ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required