notifier.go 283 B

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