asyncio: improve schedule
This commit is contained in:
17
x/io/io.go
17
x/io/io.go
@@ -78,16 +78,9 @@ func Run[OutT any](ac AsyncCall[OutT]) (OutT, error) {
|
|||||||
e.mu.Unlock()
|
e.mu.Unlock()
|
||||||
ac := e.acs[0]
|
ac := e.acs[0]
|
||||||
e.acs = e.acs[1:]
|
e.acs = e.acs[1:]
|
||||||
if ac.Done() {
|
ac.Call()
|
||||||
if ac == rootAc {
|
if ac.Done() && ac == rootAc {
|
||||||
return p.Value, p.Err
|
return p.Value, p.Err
|
||||||
}
|
|
||||||
parent := ac.parent()
|
|
||||||
if parent != nil {
|
|
||||||
parent.Resume()
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
ac.Call()
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -149,7 +142,9 @@ func (p *PromiseImpl[TOut]) Call() {
|
|||||||
}
|
}
|
||||||
p.Value = v
|
p.Value = v
|
||||||
p.Err = err
|
p.Err = err
|
||||||
p.Resume()
|
if p.Parent != nil {
|
||||||
|
p.Parent.Resume()
|
||||||
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user