clock: Bug fix: function registerd OnStart might not be called

Fixes #645
This commit is contained in:
Hajime Hoshi 2018-09-03 00:35:07 +09:00
parent d5ca4c3953
commit 3d24ffe3e0

View File

@ -30,8 +30,8 @@ var (
fpsCount = 0 fpsCount = 0
tpsCount = 0 tpsCount = 0
started bool onStartCalled bool
onStart func() onStart func()
m sync.Mutex m sync.Mutex
) )
@ -132,11 +132,11 @@ func Update(tps int) int {
m.Lock() m.Lock()
defer m.Unlock() defer m.Unlock()
if !started { if !onStartCalled {
if onStart != nil { if onStart != nil {
onStart() onStart()
onStartCalled = true
} }
started = true
} }
n := now() n := now()