mirror of
https://github.com/status-im/status-go.git
synced 2025-01-10 06:36:32 +00:00
29 lines
401 B
Go
29 lines
401 B
Go
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{})
|
|
})
|
|
}
|