Skip to content

fix(rsp): cancel arena compare background thread when TUI exits#269

Merged
elliottneilclark merged 1 commit intomasterfrom
fix/m5-arena-compare-cancellation
Apr 15, 2026
Merged

fix(rsp): cancel arena compare background thread when TUI exits#269
elliottneilclark merged 1 commit intomasterfrom
fix/m5-arena-compare-cancellation

Conversation

@elliottneilclark
Copy link
Copy Markdown
Owner

run_comparison_with_tui spawned the comparison thread, dropped the
JoinHandle, and swallowed tx.send errors inside the callback — so
after the user quit the TUI the comparison kept running, allocating a
full CFR tree per remaining permutation, and the temp output directory
could be dropped out from under the OHH historian.

Add ArenaComparison::run_with_cancellable_callback that takes a
closure returning ControlFlow<()> and short-circuits both the
permutation loop and the outer game loop on Break. Keep the existing
run_with_callback as a Continue-always convenience wrapper.

Share an Arc<AtomicBool> between the TUI-side runner and the worker
callback; the callback flips it on send failure and returns Break
so the worker stops as soon as the current permutation ends. Keep the
worker's JoinHandle, set the flag once the TUI event loop returns,
and join() the handle before returning — that keeps any caller-owned
temp directory alive until the OHH historian is done writing.

Add a regression test that run_with_cancellable_callback stops after
~3 permutations instead of running all 100 configured games.

`run_comparison_with_tui` spawned the comparison thread, dropped the
`JoinHandle`, and swallowed `tx.send` errors inside the callback — so
after the user quit the TUI the comparison kept running, allocating a
full CFR tree per remaining permutation, and the temp output directory
could be dropped out from under the OHH historian.

Add `ArenaComparison::run_with_cancellable_callback` that takes a
closure returning `ControlFlow<()>` and short-circuits both the
permutation loop and the outer game loop on `Break`. Keep the existing
`run_with_callback` as a `Continue`-always convenience wrapper.

Share an `Arc<AtomicBool>` between the TUI-side runner and the worker
callback; the callback flips it on send failure and returns `Break`
so the worker stops as soon as the current permutation ends. Keep the
worker's `JoinHandle`, set the flag once the TUI event loop returns,
and `join()` the handle before returning — that keeps any caller-owned
temp directory alive until the OHH historian is done writing.

Add a regression test that `run_with_cancellable_callback` stops after
~3 permutations instead of running all 100 configured games.
@elliottneilclark elliottneilclark merged commit 353e95c into master Apr 15, 2026
2 checks passed
@elliottneilclark elliottneilclark deleted the fix/m5-arena-compare-cancellation branch April 16, 2026 13:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant