HLE: implement XTaskQueueRegisterWaiter and XTaskQueueUnregisterWaiter #1435

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

@⁠fuzeofficlal on GitHub · 2026-11-24 17:58 UTC · original
fuzeofficlal:feat/hle-xtaskqueue-waiter-888 → main · +512 −3 · 1 files · 1 commits · closed without merging

Fixes #888.

Summary

  • Implement XTaskQueueRegisterWaiter and XTaskQueueUnregisterWaiter and wire vtable slots 20 (0xa0) and 21 (0xa8) on XTaskQueue.
  • Duplicate caller wait handles alongside a per-waiter stop event (WaitForMultipleObjects), wait for each dispatched callback to finish before re-arming manual-reset handles, purge queued waiter callbacks on unregister without deadlocking self-unregistering callbacks, and deliver canceled = true on XTaskQueueTerminate.

Verification

  • Added Win32 event tests covering auto-reset dispatch + pre-dispatch unregister purge, manual-reset re-arming + callback self-unregister on thread-pool queues, argument validation, and XTaskQueueTerminate cancellation.
  • cargo test --workspace, cargo clippy --workspace --all-targets --all-features, and cargo xtask policy: passed.
**@⁠fuzeofficlal** on GitHub · 2026-11-24 17:58 UTC · [original](https://github.com/Marvisak/VIctory/pull/1435) `fuzeofficlal:feat/hle-xtaskqueue-waiter-888` → `main` · +512 −3 · 1 files · 1 commits · closed without merging Fixes #888. ### Summary - Implement `XTaskQueueRegisterWaiter` and `XTaskQueueUnregisterWaiter` and wire vtable slots `20` (`0xa0`) and `21` (`0xa8`) on `XTaskQueue`. - Duplicate caller wait handles alongside a per-waiter stop event (`WaitForMultipleObjects`), wait for each dispatched callback to finish before re-arming manual-reset handles, purge queued waiter callbacks on unregister without deadlocking self-unregistering callbacks, and deliver `canceled = true` on `XTaskQueueTerminate`. ### Verification - Added Win32 event tests covering auto-reset dispatch + pre-dispatch unregister purge, manual-reset re-arming + callback self-unregister on thread-pool queues, argument validation, and `XTaskQueueTerminate` cancellation. - `cargo test --workspace`, `cargo clippy --workspace --all-targets --all-features`, and `cargo xtask policy`: passed.
Wire vtable slots 20 (0xa0) and 21 (0xa8) on the task-queue object to XTaskQueueRegisterWaiter and XTaskQueueUnregisterWaiter.

Duplicate the caller's Win32 wait handle alongside a per-waiter stop event, wait for each delivered callback to finish before re-arming WaitForMultipleObjects, purge un-dispatched waiter tasks and await external in-flight callbacks on unregister without deadlocking self-unregistering callbacks, and cancel registered waiters on XTaskQueueTerminate.

Closes #888
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 04:31:38 +00:00
github-bot closed this pull request 2026-11-26 04:31:38 +00:00
Author
Owner

@⁠Marvisak on GitHub · 2026-11-25 01:28 UTC · original · edited 2026-11-25 06:29 UTC

Automated triage for the maintainers.

Needs work. It merges cleanly. The PR wires slots 0xa0 and 0xa8 of the task-queue object (crates/victory-hle/src/modules/xasync.rs) to a waiter implementation: a duplicated handle and a stop event, one OS thread per waiter in waiter_loop, re-arming after each callback, and cleanup on unregister, XTaskQueueTerminate and Queue::drop. I read through the locking and found no deadlock. Self-unregistering from the callback, and dropping the last queue reference on the waiter thread, both skip the join correctly. What it needs:

  • Evidence the title uses these slots. On main, both slots go to missing::<20> / missing::<21>, which log runtime method not implemented with the slot. A log line showing the title calls 0xa0 would justify 500 lines and a thread per waiter. Without one, this adds runtime behaviour nobody has seen needed.
  • Evidence for the terminate semantics. XTaskQueueTerminate now calls every registered waiter's callback once with canceled = true, and the test pins that. Please point to public documentation or observed behaviour for that, because a waiter that was never signalled might also just be dropped silently.

The same patch was first posted on a fork in #888 by another contributor. Please credit them, or say how the two relate.

CI: passing (check).


Generated by Claude Code

**@⁠Marvisak** on GitHub · 2026-11-25 01:28 UTC · [original](https://github.com/Marvisak/VIctory/pull/1435#issuecomment-7149579514) · edited 2026-11-25 06:29 UTC <!-- victory-triage v1 head=13fef7a28a7a3ffe297b3459a1b3b79e37e8f2d0 verdict=needs-work at=2026-11-25T06:29:35Z --> Automated triage for the maintainers. **Needs work.** It merges cleanly. The PR wires slots 0xa0 and 0xa8 of the task-queue object (`crates/victory-hle/src/modules/xasync.rs`) to a waiter implementation: a duplicated handle and a stop event, one OS thread per waiter in `waiter_loop`, re-arming after each callback, and cleanup on unregister, `XTaskQueueTerminate` and `Queue::drop`. I read through the locking and found no deadlock. Self-unregistering from the callback, and dropping the last queue reference on the waiter thread, both skip the join correctly. What it needs: - **Evidence the title uses these slots.** On `main`, both slots go to `missing::<20>` / `missing::<21>`, which log `runtime method not implemented` with the slot. A log line showing the title calls 0xa0 would justify 500 lines and a thread per waiter. Without one, this adds runtime behaviour nobody has seen needed. - **Evidence for the terminate semantics.** `XTaskQueueTerminate` now calls every registered waiter's callback once with `canceled = true`, and the test pins that. Please point to public documentation or observed behaviour for that, because a waiter that was never signalled might also just be dropped silently. The same patch was first posted on a fork in #888 by another contributor. Please credit them, or say how the two relate. CI: passing (`check`). --- _Generated by [Claude Code](https://claude.ai/code)_
Author
Owner

@⁠fuzeofficlal on GitHub · 2026-11-25 17:20 UTC · original

Closing this PR: as noted in triage, adding the XTaskQueue 0xa0/0xa8 implementation without title call-site logs is premature. Happy to revisit if a title hits those slots.

**@⁠fuzeofficlal** on GitHub · 2026-11-25 17:20 UTC · [original](https://github.com/Marvisak/VIctory/pull/1435#issuecomment-7169357359) Closing this PR: as noted in triage, adding the `XTaskQueue` `0xa0`/`0xa8` implementation without title call-site logs is premature. Happy to revisit if a title hits those slots.

Pull request closed

This discussion has been locked. Commenting is limited to contributors.
No reviewers
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.

Dependencies

No dependencies set

Reference
github/Marvisak--VIctory!1435
No description provided.