// Notifier is an utility for notifying changes. The change producer may notify changes multiple time, and the consumer may get notified asychronously.
typeNotifierstruct{
cchanstruct{}
}
// NewNotifier creates a new Notifier.
funcNewNotifier()*Notifier{
return&Notifier{
c:make(chanstruct{},1),
}
}
// Signal signals a change, usually by producer. This method never blocks.
func(n*Notifier)Signal(){
select{
casen.c<-struct{}{}:
@ -17,6 +20,7 @@ func (n *Notifier) Signal() {
}
}
// Wait returns a channel for waiting for changes. The returned channel never gets closed.