mirror of https://github.com/v2ray/v2ray-core
23 lines
265 B
Go
23 lines
265 B
Go
![]() |
package signal
|
||
|
|
||
|
type Notifier struct {
|
||
|
c chan bool
|
||
|
}
|
||
|
|
||
|
func NewNotifier() *Notifier {
|
||
|
return &Notifier{
|
||
|
c: make(chan bool, 1),
|
||
|
}
|
||
|
}
|
||
|
|
||
|
func (n *Notifier) Signal() {
|
||
|
select {
|
||
|
case n.c <- true:
|
||
|
default:
|
||
|
}
|
||
|
}
|
||
|
|
||
|
func (n *Notifier) Wait() <-chan bool {
|
||
|
return n.c
|
||
|
}
|