From 8902d95b2dc2a9c1d349126d5e65d817b5467cc0 Mon Sep 17 00:00:00 2001 From: Hajime Hoshi Date: Fri, 30 Dec 2022 13:52:05 +0900 Subject: [PATCH] internal/ui: remove unused function runOnAnotherThreadFromMainThread --- internal/ui/run_notsinglethread.go | 25 ------------------------- internal/ui/run_singlethread.go | 4 ---- 2 files changed, 29 deletions(-) diff --git a/internal/ui/run_notsinglethread.go b/internal/ui/run_notsinglethread.go index 5a1e5e6a0..63968e9ce 100644 --- a/internal/ui/run_notsinglethread.go +++ b/internal/ui/run_notsinglethread.go @@ -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) -} diff --git a/internal/ui/run_singlethread.go b/internal/ui/run_singlethread.go index 81a691252..d2242374d 100644 --- a/internal/ui/run_singlethread.go +++ b/internal/ui/run_singlethread.go @@ -41,7 +41,3 @@ func (u *userInterfaceImpl) Run(game Game, options *RunOptions) error { return nil } - -func (u *userInterfaceImpl) runOnAnotherThreadFromMainThread(f func()) { - f() -}