mirror of
https://github.com/hajimehoshi/ebiten.git
synced 2024-12-24 18:58:54 +01:00
graphics: Refactoring: remove ui goroutines
This commit is contained in:
parent
1062902872
commit
5cfefaf1a2
@ -49,13 +49,7 @@ func Init() {
|
|||||||
|
|
||||||
u := &userInterface{
|
u := &userInterface{
|
||||||
window: window,
|
window: window,
|
||||||
funcs: make(chan func()),
|
|
||||||
}
|
}
|
||||||
go func() {
|
|
||||||
for f := range u.funcs {
|
|
||||||
f()
|
|
||||||
}
|
|
||||||
}()
|
|
||||||
go func() {
|
go func() {
|
||||||
runtime.LockOSThread()
|
runtime.LockOSThread()
|
||||||
u.window.MakeContextCurrent()
|
u.window.MakeContextCurrent()
|
||||||
@ -67,13 +61,7 @@ func Init() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func ExecOnUIThread(f func()) {
|
func ExecOnUIThread(f func()) {
|
||||||
// TODO: Rename this function: f is actually NOT executed on UI threads
|
f()
|
||||||
ch := make(chan struct{})
|
|
||||||
currentUI.funcs <- func() {
|
|
||||||
defer close(ch)
|
|
||||||
f()
|
|
||||||
}
|
|
||||||
<-ch
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func Start(width, height, scale int, title string) (actualScale int, err error) {
|
func Start(width, height, scale int, title string) (actualScale int, err error) {
|
||||||
@ -112,7 +100,6 @@ type userInterface struct {
|
|||||||
height int
|
height int
|
||||||
scale int
|
scale int
|
||||||
actualScale int
|
actualScale int
|
||||||
funcs chan func()
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (u *userInterface) start(width, height, scale int, title string) (actualScale int, err error) {
|
func (u *userInterface) start(width, height, scale int, title string) (actualScale int, err error) {
|
||||||
|
Loading…
Reference in New Issue
Block a user