graphics: Refactoring: remove ui goroutines

This commit is contained in:
Hajime Hoshi 2016-02-20 04:08:06 +09:00
parent 1062902872
commit 5cfefaf1a2

View File

@ -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) {