status-go/vendor/github.com/anacrolix/missinggo/event_synchronized.go

27 lines
368 B
Go
Raw Permalink Normal View History

2022-03-10 09:44:48 +00:00
package missinggo
import "sync"
type SynchronizedEvent struct {
mu sync.Mutex
e Event
}
func (me *SynchronizedEvent) Set() {
me.mu.Lock()
me.e.Set()
me.mu.Unlock()
}
func (me *SynchronizedEvent) Clear() {
me.mu.Lock()
me.e.Clear()
me.mu.Unlock()
}
func (me *SynchronizedEvent) C() <-chan struct{} {
me.mu.Lock()
defer me.mu.Unlock()
return me.e.C()
}