internal/ui: remove unused function runOnAnotherThreadFromMainThread

This commit is contained in:
Hajime Hoshi 2022-12-30 13:52:05 +09:00
parent e1992347b7
commit 8902d95b2d
2 changed files with 0 additions and 29 deletions

View File

@ -59,28 +59,3 @@ func (u *userInterfaceImpl) Run(game Game, options *RunOptions) error {
}
return err
}
// runOnAnotherThreadFromMainThread is called from the main thread, and calls f on a new goroutine (thread).
// runOnAnotherThreadFromMainThread creates a new nested main thread and runs the run loop.
// u.mainThread is updated to the new thread until runOnAnotherThreadFromMainThread is called.
//
// Inside f, another functions that must be called from the main thread can be called safely.
func (u *userInterfaceImpl) runOnAnotherThreadFromMainThread(f func()) {
// As this function is called from the main thread, u.mainThread should never be accessed and can be updated here.
t := u.mainThread
defer func() {
u.mainThread = t
graphicscommand.SetRenderThread(t)
}()
u.mainThread = thread.NewOSThread()
graphicscommand.SetRenderThread(u.mainThread)
ctx, cancel := stdcontext.WithCancel(stdcontext.Background())
defer cancel()
go func() {
defer cancel()
f()
}()
_ = u.mainThread.Loop(ctx)
}

View File

@ -41,7 +41,3 @@ func (u *userInterfaceImpl) Run(game Game, options *RunOptions) error {
return nil
}
func (u *userInterfaceImpl) runOnAnotherThreadFromMainThread(f func()) {
f()
}