status-go/vendor/github.com/anacrolix/chansync/level.go

29 lines
401 B
Go
Raw Normal View History

2022-03-10 09:44:48 +00:00
package chansync
import (
"sync"
"github.com/anacrolix/chansync/events"
)
type LevelTrigger struct {
ch chan struct{}
initOnce sync.Once
}
func (me *LevelTrigger) Signal() events.Signal {
me.init()
return me.ch
}
func (me *LevelTrigger) Active() events.Active {
me.init()
return me.ch
}
func (me *LevelTrigger) init() {
me.initOnce.Do(func() {
me.ch = make(chan struct{})
})
}