diff options
| author | historia <[not public]> | 2026-09-15 15:35:52 -0400 |
|---|---|---|
| committer | historia <[not public]> | 2026-09-15 15:35:52 -0400 |
| commit | 0b0b25222b3131ada79ff78c28eb8bf07d977deb (patch) | |
| tree | 2ceaef5203595044f66a8f00064cd8e017f8f48d /internal/engine | |
| parent | 396c3facb8287b9a34076cae8f3d7b300d366d99 (diff) | |
| download | thehouseoficarus-0b0b25222b3131ada79ff78c28eb8bf07d977deb.tar.gz | |
feat: single-owner game state, transactional lifecycle, durable money on server stop
Diffstat (limited to 'internal/engine')
| -rw-r--r-- | internal/engine/tick.go | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/internal/engine/tick.go b/internal/engine/tick.go index 00a9c60..74b1dcf 100644 --- a/internal/engine/tick.go +++ b/internal/engine/tick.go @@ -93,6 +93,16 @@ func (e *Engine) Stop() { } } +// StopAndWait stops the ticker AND joins any in-flight callback: it waits +// until the currently running tick has completed and the loop goroutine has +// exited. Use this for graceful shutdown, where the final tick must finish +// before owned state is saved. +func (e *Engine) StopAndWait() { + e.Stop() + e.tickMu.Lock() + e.tickMu.Unlock() +} + // Tick fires every due subscriber synchronously and returns. Subscribers // are invoked in ascending subscription-ID (registration) order. Tick calls // are serialized; a callback must not call Tick recursively. |
