1
0
mirror of https://github.com/v2fly/v2ray-core.git synced 2024-11-17 18:06:15 -05:00
v2fly/common/signal/notifier.go

23 lines
283 B
Go
Raw Normal View History

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