February 2018
Intermediate to advanced
246 pages
6h 3m
English
Before we try to solve the problem, let's first formulate what we want to achieve:
Let's look at one possible solution that tries to solve the cashier problem using the preceding steps:
// wichan.go package main import ( "fmt" "sync" ) func cashier(cashierID int, orderChannel <-chan int, wg *sync.WaitGroup) { // Process orders upto limit. for ordersProcessed := 0; ordersProcessed < 10; ordersProcessed++ { // Retrieve order from orderChannel orderNum := <-orderChannel // Cashier is ready to serve! ...Read now
Unlock full access