XGameRuntime: terminate cancels a delayed callback #198

Closed
davutsimsekk wants to merge 1 commit from upstream-pr/198 into main
davutsimsekk commented 2026-11-24 22:29:13 +00:00 (Migrated from github.com)

Imported from fxceless/victory-fork. Originally posted by davutsimsekk on 2026-11-24T22:29:13Z.


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.
<!-- greyfinch-sync:fxceless/victory-fork:issue:6592690186 --> Imported from [fxceless/victory-fork](https://github.com/fxceless/victory-fork/pull/198). Originally posted by [davutsimsekk](https://github.com/davutsimsekk) on 2026-11-24T22:29:13Z. --- `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.
upstream-sync closed this pull request 2026-11-25 04:10:57 +00:00
davutsimsekk commented 2026-11-25 04:11:21 +00:00 (Migrated from github.com)

Imported from fxceless/victory-fork. Originally posted by davutsimsekk on 2026-11-25T03:37:48Z.


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

<!-- greyfinch-sync:fxceless/victory-fork:comment:7152094940 --> Imported from [fxceless/victory-fork](https://github.com/fxceless/victory-fork/pull/198#issuecomment-7152094940). Originally posted by [davutsimsekk](https://github.com/davutsimsekk) on 2026-11-25T03:37:48Z. --- 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

Sign in to join this conversation.
No reviewers
No labels
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Reference
fxceless/victory-fork!198
No description provided.