1
0
Fork 0
mirror of https://github.com/vbatts/talks.git synced 2025-06-04 11:02:29 +00:00

files from getdown that need to be reconciled

This commit is contained in:
Vincent Batts 2018-09-14 12:55:35 -04:00
parent 8e251effd9
commit 6943db29ba
36 changed files with 1297 additions and 0 deletions

View file

@ -0,0 +1,20 @@
package main
// START OMIT
var ngoroutine = 100000
func f(left, right chan int) { left <- 1 + <-right }
func main() {
leftmost := make(chan int)
var left, right chan int = nil, leftmost
for i := 0; i < ngoroutine; i++ {
left, right = right, make(chan int)
go f(left, right)
}
right <- 0 // bang!
x := <-leftmost // wait for completion
println(x) // 100000
}
// STOP OMIT