On Wed, Dec 9, 2009 at 22:03, John Asmuth <
jas...@gmail.com> wrote:
> In this case, at least, I found a way around it. In general, I wonder
> if a Trigger() function, that takes a indicator function and returns a
> channel, sending a value on the channel the first time the indicator
> is true, would be useful...
This is not the way to think about things in Go.
The Go way is to make foo a func() with no
return value; calling it would block until the
channel should be written to. The even more
idiomatic Go way would be to make foo a
channel instead of a function:
func Trigger(req chan bool) chan bool {
c := make(chan bool)
go func() {
<-c
req <- true
}
return c
}
Any time you would use polling in a traditional
event-based system, think about using blocking
instead in Go.
Russ