diff options
author | Rob Pike <r@golang.org> | 2008-09-16 19:40:38 -0700 |
---|---|---|
committer | Rob Pike <r@golang.org> | 2008-09-16 19:40:38 -0700 |
commit | effe64dd61b262994b7ee18c55c4f64aa88c19d5 (patch) | |
tree | 4134100521d51a61dc0409d6f7e22421c53fbdf9 /doc/progs | |
parent | 42a99047caf2db7cfaf4901ec69e5dcd17d76b76 (diff) | |
download | golang-effe64dd61b262994b7ee18c55c4f64aa88c19d5.tar.gz |
update to new communications syntax
R=gri
OCL=15417
CL=15417
Diffstat (limited to 'doc/progs')
-rw-r--r-- | doc/progs/server.go | 4 | ||||
-rw-r--r-- | doc/progs/server1.go | 9 | ||||
-rw-r--r-- | doc/progs/sieve.go | 4 | ||||
-rw-r--r-- | doc/progs/sieve1.go | 6 |
4 files changed, 11 insertions, 12 deletions
diff --git a/doc/progs/server.go b/doc/progs/server.go index 00bc3b96d..ea089785d 100644 --- a/doc/progs/server.go +++ b/doc/progs/server.go @@ -13,7 +13,7 @@ type BinOp (a, b int) int; func Run(op *BinOp, request *Request) { result := op(request.a, request.b); - request.replyc -< result; + request.replyc <- result; } func Server(op *BinOp, service *chan *Request) { @@ -38,7 +38,7 @@ func main() { req.a = i; req.b = i + N; req.replyc = new(chan int); - adder -< req; + adder <- req; } for i := N-1; i >= 0; i-- { // doesn't matter what order if <-reqs[i].replyc != N + 2*i { diff --git a/doc/progs/server1.go b/doc/progs/server1.go index 9f6c709b3..69bf22d87 100644 --- a/doc/progs/server1.go +++ b/doc/progs/server1.go @@ -13,14 +13,13 @@ type BinOp (a, b int) int; func Run(op *BinOp, request *Request) { result := op(request.a, request.b); - request.replyc -< result; + request.replyc <- result; } func Server(op *BinOp, service *chan *Request, quit *chan bool) { for { - var request *Request; select { - case request <- service: + case request := <-service: go Run(op, request); // don't wait for it case <-quit: return; @@ -44,12 +43,12 @@ func main() { req.a = i; req.b = i + N; req.replyc = new(chan int); - adder -< req; + adder <- req; } for i := N-1; i >= 0; i-- { // doesn't matter what order if <-reqs[i].replyc != N + 2*i { print("fail at ", i, "\n"); } } - quit -< true; + quit <- true; } diff --git a/doc/progs/sieve.go b/doc/progs/sieve.go index 60760cf4e..2ee3bb7ff 100644 --- a/doc/progs/sieve.go +++ b/doc/progs/sieve.go @@ -7,7 +7,7 @@ package main // Send the sequence 2, 3, 4, ... to channel 'ch'. func Generate(ch *chan int) { for i := 2; ; i++ { - ch -< i // Send 'i' to channel 'ch'. + ch <- i // Send 'i' to channel 'ch'. } } @@ -17,7 +17,7 @@ func Filter(in *chan int, out *chan int, prime int) { for { i := <-in // Receive value of new variable 'i' from 'in'. if i % prime != 0 { - out -< i // Send 'i' to channel 'out'. + out <- i // Send 'i' to channel 'out'. } } } diff --git a/doc/progs/sieve1.go b/doc/progs/sieve1.go index 2d6e069f4..d1c3c7277 100644 --- a/doc/progs/sieve1.go +++ b/doc/progs/sieve1.go @@ -9,7 +9,7 @@ func Generate() *chan int { ch := new(chan int); go func(ch *chan int){ for i := 2; ; i++ { - ch -< i + ch <- i } }(ch); return ch; @@ -21,7 +21,7 @@ func Filter(in *chan int, prime int) *chan int { go func(in *chan int, out *chan int, prime int) { for { if i := <-in; i % prime != 0 { - out -< i + out <- i } } }(in, out, prime); @@ -34,7 +34,7 @@ func Sieve() *chan int { ch := Generate(); for { prime := <-ch; - out -< prime; + out <- prime; ch = Filter(ch, prime); } }(out); |