1
0
mirror of https://github.com/v2fly/v2ray-core.git synced 2026-05-28 06:49:07 -04:00

migrate to signal.Semaphore and Notifier

This commit is contained in:
Darien Raymond
2017-12-27 21:33:42 +01:00
parent 664b840812
commit 8a09c6c926
3 changed files with 215 additions and 224 deletions

22
common/signal/notifier.go Normal file
View File

@@ -0,0 +1,22 @@
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
}