-
-
Save mkevac/2006f7fa8be38fb1ee00 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"github.com/davecheney/profile" | |
) | |
func loop(in chan *int) { | |
var n int | |
for { | |
select { | |
case <-in: | |
case in <- &n: | |
} | |
} | |
} | |
func main() { | |
defer profile.Start(profile.MemProfile).Stop() | |
c := make(chan *int) | |
go loop(c) | |
for { | |
var n int | |
c <- &n | |
<-c | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment