예제 #1
0
파일: chain.go 프로젝트: 8l/go-learn
func link(left chan<- int, right <-chan int) {
	// Keep the links in dedicated operating system
	// threads, so that this program tests coordination
	// between pthreads and not just goroutines.
	runtime.LockOSThread()
	for {
		v := <-right
		stdio.Puts(strconv.Itoa(v))
		left <- 1 + v
	}
}
예제 #2
0
파일: chain.go 프로젝트: 8l/go-learn
func main() {
	leftmost := make(chan int)
	var left chan int
	right := leftmost
	for i := 0; i < N; i++ {
		left, right = right, make(chan int)
		go link(left, right)
	}
	for i := 0; i < R; i++ {
		right <- 0
		x := <-leftmost
		stdio.Puts(strconv.Itoa(x))
	}
}
예제 #3
0
파일: fib.go 프로젝트: ivanwyc/google-go
func fibber(c, out chan int64, i int64) {
	// Keep the fibbers in dedicated operating system
	// threads, so that this program tests coordination
	// between pthreads and not just goroutines.
	runtime.LockOSThread()

	if i == 0 {
		c <- i
	}
	for {
		j := <-c
		stdio.Puts(strconv.Itoa64(j))
		out <- j
		<-out
		i += j
		c <- i
	}
}
예제 #4
0
func main() {
	//	stdio.Stdout.WriteString("hello, world\n");
	stdio.Puts("hello, world")
}