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:
22
common/signal/notifier.go
Normal file
22
common/signal/notifier.go
Normal 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
|
||||
}
|
||||
Reference in New Issue
Block a user