chore: bump periph.io dependencies

This commit is contained in:
2022-01-02 23:37:01 +01:00
parent 0b8d2218c1
commit c1ec63fcc1
63 changed files with 506 additions and 5328 deletions

View File

@ -5,6 +5,7 @@
// This file contains the parallelized driver loading logic. It is meant to be
// load the drivers as fast as possible by parallelising work.
//go:build !tinygo
// +build !tinygo
package driverreg
@ -50,9 +51,11 @@ func initImpl() (*State, error) {
if err != nil {
return state, err
}
loaded := make(map[string]struct{}, len(byName))
loaded := sync.Map{}
for _, s := range stages {
s.loadParallel(loaded, cD, cS, cE)
// It's very important that each of the stage is fully completed before the
// next one is attempted.
s.loadParallel(&loaded, cD, cS, cE)
}
close(cD)
close(cS)
@ -61,10 +64,9 @@ func initImpl() (*State, error) {
return state, nil
}
// loadParallel loads all the drivers for this stage in parallel.
//
// Updates loaded in a safe way.
func (s *stage) loadParallel(loaded map[string]struct{}, cD chan<- driver.Impl, cS, cE chan<- DriverFailure) {
// loadParallel loads all the drivers for this stage in parallel and returns
// once they are all loaded.
func (s *stage) loadParallel(loaded *sync.Map, cD chan<- driver.Impl, cS, cE chan<- DriverFailure) {
success := make(chan string)
go func() {
defer close(success)
@ -73,7 +75,7 @@ func (s *stage) loadParallel(loaded map[string]struct{}, cD chan<- driver.Impl,
for name, drv := range s.drvs {
// Intentionally do not look at After(), only Prerequisites().
for _, dep := range drv.Prerequisites() {
if _, ok := loaded[dep]; !ok {
if _, ok := loaded.Load(dep); !ok {
cS <- DriverFailure{drv, errors.New("dependency not loaded: " + strconv.Quote(dep))}
continue loop
}
@ -98,6 +100,6 @@ func (s *stage) loadParallel(loaded map[string]struct{}, cD chan<- driver.Impl,
wg.Wait()
}()
for s := range success {
loaded[s] = struct{}{}
loaded.Store(s, nil)
}
}

View File

@ -5,6 +5,7 @@
// This file contains the single threaded driver loading code, to be used on
// low performance cores.
//go:build tinygo
// +build tinygo
package driverreg