mirror of
https://github.com/hajimehoshi/ebiten.git
synced 2025-01-12 12:08:58 +01:00
uidriver/mobile: Refactoring
This commit is contained in:
parent
8c779447db
commit
f332fa61c1
@ -17,7 +17,6 @@
|
|||||||
package mobile
|
package mobile
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
|
||||||
"fmt"
|
"fmt"
|
||||||
"runtime"
|
"runtime"
|
||||||
"runtime/debug"
|
"runtime/debug"
|
||||||
@ -89,14 +88,13 @@ func (u *UserInterface) Update() error {
|
|||||||
panic("mobile: glWorker must be initialized but not")
|
panic("mobile: glWorker must be initialized but not")
|
||||||
}
|
}
|
||||||
|
|
||||||
ctx, cancel := context.WithCancel(context.Background())
|
done := make(chan struct{})
|
||||||
go func() {
|
go func() {
|
||||||
<-renderEndCh
|
<-renderEndCh
|
||||||
cancel()
|
close(done)
|
||||||
}()
|
}()
|
||||||
|
|
||||||
workAvailable := u.glWorker.WorkAvailable()
|
workAvailable := u.glWorker.WorkAvailable()
|
||||||
loop:
|
|
||||||
for {
|
for {
|
||||||
select {
|
select {
|
||||||
case <-workAvailable:
|
case <-workAvailable:
|
||||||
@ -106,11 +104,10 @@ func (u *UserInterface) Update() error {
|
|||||||
// Apprently there is an issue in the usage of Worker in gomobile or gomobile itself.
|
// Apprently there is an issue in the usage of Worker in gomobile or gomobile itself.
|
||||||
// At least, freezing doesn't happen with this Gosched.
|
// At least, freezing doesn't happen with this Gosched.
|
||||||
runtime.Gosched()
|
runtime.Gosched()
|
||||||
case <-ctx.Done():
|
case <-done:
|
||||||
break loop
|
return nil
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return nil
|
|
||||||
}
|
}
|
||||||
|
|
||||||
go func() {
|
go func() {
|
||||||
|
Loading…
Reference in New Issue
Block a user