v2ray-core/common/signal/notifier.go

23 lines
283 B
Go
Raw Normal View History

package signal
type Notifier struct {
2018-02-08 14:39:46 +00:00
c chan struct{}
}
func NewNotifier() *Notifier {
return &Notifier{
2018-02-08 14:39:46 +00:00
c: make(chan struct{}, 1),
}
}
func (n *Notifier) Signal() {
select {
2018-02-08 14:39:46 +00:00
case n.c <- struct{}{}:
default:
}
}
2018-02-08 14:39:46 +00:00
func (n *Notifier) Wait() <-chan struct{} {
return n.c
}