notifier.go 265 B

12345678910111213141516171819202122
  1. package signal
  2. type Notifier struct {
  3. c chan bool
  4. }
  5. func NewNotifier() *Notifier {
  6. return &Notifier{
  7. c: make(chan bool, 1),
  8. }
  9. }
  10. func (n *Notifier) Signal() {
  11. select {
  12. case n.c <- true:
  13. default:
  14. }
  15. }
  16. func (n *Notifier) Wait() <-chan bool {
  17. return n.c
  18. }