Jump to content

Rendezvous: Difference between revisions

→‎{{header|Go}}: updated to use new WaitGroup feature. also improved exception message.
(Go solution)
(→‎{{header|Go}}: updated to use new WaitGroup feature. also improved exception message.)
Line 230:
"fmt"
"strings"
"sync"
)
 
Line 249 ⟶ 250:
reservePrinter := startMonitor(newPrinter(5), nil)
mainPrinter := startMonitor(newPrinter(5), reservePrinter)
var busy sync.WaitGroup
 
hdDone := makebusy.Add(chan int2)
go writer(mainPrinter, mgText"hd", mgDonehdText, &busy)
mgDone := make(chan int)
go writer(mainPrinter, hdText"mg", hdDonemgText, &busy)
busy.Wait()
go writer(mainPrinter, mgText, mgDone)
<-hdDone
<-mgDone
}
 
Line 303 ⟶ 302:
}
 
func writer(printer *rSync, id, text string, done chanbusy int*sync.WaitGroup) {
for _, line := range strings.Split(text, "\n", -1) {
if e := printer.rendezvous(line); e != nil {
fmt.Println("**** writerprint receivedjob", exceptionid, "terminated:", e, "****")
break
}
}
done <- 0busy.Done()
}</lang>
Output:
<pre>Old Mother Goose,
Old Mother Goose,
Humpty Dumpty sat on a wall.
Humpty Dumpty had a great fall.
Line 323:
Jack's mother came in,
And caught the goose soon,
**** writerprint receivedjob exceptionmg terminated: out of ink ****</pre>
</pre>
 
=={{header|Oz}}==
1,707

edits

Cookies help us deliver our services. By using our services, you agree to our use of cookies.