YTSFlix_Go/vendor/github.com/anacrolix/missinggo/wait_event.go

20 lines
336 B
Go
Raw Normal View History

2018-11-04 14:58:15 +00:00
package missinggo
import (
"reflect"
"sync"
)
func WaitEvents(l sync.Locker, evs ...*Event) {
cases := make([]reflect.SelectCase, 0, len(evs))
for _, ev := range evs {
cases = append(cases, reflect.SelectCase{
Dir: reflect.SelectRecv,
Chan: reflect.ValueOf(ev.C()),
})
}
l.Unlock()
reflect.Select(cases)
l.Lock()
}