Sha256: f9d76106ad13bb14212dd876c4b47c5981c55d60b631cd8830392f994bb57a2e

Contents?: true

Size: 474 Bytes

Versions: 15

Compression:

Stored size: 474 Bytes

Contents

package main

import (
  "fmt"
  "runtime"
)

func producer(c chan int, N int, s chan bool) {
  for i := 0; i < N; i++ {
    fmt.Printf("producer: %d\n", i)
    c <- i
  }
  s <- true
}

func consumer(c chan int, N int, s chan bool) {
  for i := 0; i < N; i++ {
    fmt.Printf("consumer got: %d\n", <- c)
  }
  s <- true
}

func main() {
  runtime.GOMAXPROCS(2)

  c := make(chan int)
  s := make(chan bool)

  go producer(c, 10, s)
  go consumer(c, 10, s)

  <- s
  <- s
}

Version data entries

15 entries across 15 versions & 2 rubygems

Version Path
em-synchrony-1.0.6 examples/go/consumer-publisher.go
agent-0.12.0 spec/examples/go/producer_consumer.go
em-synchrony-1.0.5 examples/go/consumer-publisher.go
agent-0.11.0 spec/examples/go/producer_consumer.go
agent-0.10.0 spec/examples/go/producer_consumer.go
em-synchrony-1.0.4 examples/go/consumer-publisher.go
agent-0.9.1 spec/examples/go/producer_consumer.go
em-synchrony-1.0.3 examples/go/consumer-publisher.go
em-synchrony-1.0.2 examples/go/consumer-publisher.go
em-synchrony-1.0.1 examples/go/consumer-publisher.go
agent-0.9.0 spec/examples/go/producer_consumer.go
em-synchrony-1.0.0 examples/go/consumer-publisher.go
em-synchrony-0.3.0.beta.1 examples/go/consumer-publisher.go
agent-0.1.0 spec/examples/go/producer_consumer.go
em-synchrony-0.2.0 examples/go/consumer-publisher.go