aboutsummaryrefslogtreecommitdiff
path: root/internal/engine
diff options
context:
space:
mode:
Diffstat (limited to 'internal/engine')
-rw-r--r--internal/engine/tick.go5
1 files changed, 4 insertions, 1 deletions
diff --git a/internal/engine/tick.go b/internal/engine/tick.go
index 74b1dcf..63ee6af 100644
--- a/internal/engine/tick.go
+++ b/internal/engine/tick.go
@@ -99,8 +99,11 @@ func (e *Engine) Stop() {
// before owned state is saved.
func (e *Engine) StopAndWait() {
e.Stop()
+ // Join any in-flight tick: processTick holds tickMu for its whole body,
+ // so acquiring the mutex blocks until the running callback completes;
+ // holding it until return keeps that guarantee for the caller.
e.tickMu.Lock()
- e.tickMu.Unlock()
+ defer e.tickMu.Unlock()
}
// Tick fires every due subscriber synchronously and returns. Subscribers