Hi.
Closing channel to broadcast Cancellation or Done event is proven
pattern in Go.
go func(){
for{
select{
case <-signal:
//canselation
default:
//default
}
}
}
//...
close(signal)
But we can signal only once this way. May we cheat a bit?
var closed = make(chan struct{})
close(closed)
var blocked chan struct{}
var signal chan struct{}
//and than switch to emit events
signal = closed
//...
signal = blocked
//...
signal = closed
//...
signal = blocked
Does it considered meaningful or/and at least safe?
--
Ilya Kostarev
--
You received this message because you are subscribed to the Google Groups
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to golang-nuts+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.