XGameRuntime: terminate cancels a delayed callback #198

Closed
github-bot wants to merge 1 commit from gh-pr/198/head into gh-pr/198/base
Owner

@⁠davutsimsekk on GitHub · 2026-11-24 22:29 UTC · original
davutsimsekk:fix/taskqueue-terminate-delayed → main · +35 −0 · 1 files · 1 commits · closed without merging

XTaskQueueTerminate cancels callbacks already in a port's queue, but a callback still parked on its delay is invisible: it is on a sleeper thread and only reaches the port when the sleep ends. After termination it was delivered and run with canceled = false, and a later XTaskQueueDispatch returned work on a terminated queue.

The GDK contract is that termination invokes every pending callback with canceled = true, and dispatch returns false once the queue is terminated.

This makes Queue::deliver cancel the task when the queue is terminated instead of submitting it late. Normal delivery and termination of already-queued tasks are unchanged.

Test

terminate_cancels_a_callback_still_on_its_delay creates a manual queue, submits a 100 ms delayed callback, terminates, waits past the delay, then asserts dispatch is false and the callback saw canceled = true. On main the callback runs with canceled = false and dispatch returns true.

  • cargo test -p victory-hle --lib: 96 passed, 0 failed
  • cargo clippy -p victory-hle --all-targets --locked -- -D warnings: clean
  • The changed hunks are rustfmt-clean; the file has unrelated pre-existing formatting.
  • The title was not run.
**@⁠davutsimsekk** on GitHub · 2026-11-24 22:29 UTC · [original](https://github.com/fxceless/victory-fork/pull/198) `davutsimsekk:fix/taskqueue-terminate-delayed` → `main` · +35 −0 · 1 files · 1 commits · closed without merging `XTaskQueueTerminate` cancels callbacks already in a port's queue, but a callback still parked on its delay is invisible: it is on a sleeper thread and only reaches the port when the sleep ends. After termination it was delivered and run with `canceled = false`, and a later `XTaskQueueDispatch` returned work on a terminated queue. The GDK contract is that termination invokes every pending callback with `canceled = true`, and dispatch returns false once the queue is terminated. This makes `Queue::deliver` cancel the task when the queue is terminated instead of submitting it late. Normal delivery and termination of already-queued tasks are unchanged. ## Test `terminate_cancels_a_callback_still_on_its_delay` creates a manual queue, submits a 100 ms delayed callback, terminates, waits past the delay, then asserts dispatch is false and the callback saw `canceled = true`. On `main` the callback runs with `canceled = false` and dispatch returns true. - `cargo test -p victory-hle --lib`: 96 passed, 0 failed - `cargo clippy -p victory-hle --all-targets --locked -- -D warnings`: clean - The changed hunks are rustfmt-clean; the file has unrelated pre-existing formatting. - The title was not run.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 03:38:03 +00:00
github-bot closed this pull request 2026-11-26 03:38:03 +00:00
Author
Owner

@⁠davutsimsekk on GitHub · 2026-11-25 03:37 UTC · original

Superseded by #584, which cancels delayed timers and scopes composite queue termination. Closing this narrow version to keep one fix per area.

**@⁠davutsimsekk** on GitHub · 2026-11-25 03:37 UTC · [original](https://github.com/fxceless/victory-fork/pull/198#issuecomment-7152094940) Superseded by #584, which cancels delayed timers and scopes composite queue termination. Closing this narrow version to keep one fix per area.

Pull request closed

This discussion has been locked. Commenting is limited to contributors.
No description provided.