HLE: implement XTaskQueueRegisterWaiter and XTaskQueueUnregisterWaiter #1434

Closed
fuzeofficlal wants to merge 1 commit from upstream-pr/1435 into main
fuzeofficlal commented 2026-11-24 17:58:16 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by fuzeofficlal on 2026-11-24T17:58:16Z.


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.
<!-- greyfinch-sync:Marvisak/VIctory:issue:6588134355 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/1435). Originally posted by [fuzeofficlal](https://github.com/fuzeofficlal) on 2026-11-24T17:58:16Z. --- 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.
Marvisak commented 2026-11-25 02:06:05 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by Marvisak on 2026-11-25T01:28:06Z.


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

<!-- greyfinch-sync:Marvisak/VIctory:comment:7149579514 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/1435#issuecomment-7149579514). Originally posted by [Marvisak](https://github.com/Marvisak) on 2026-11-25T01:28:06Z. --- <!-- 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)_
upstream-sync closed this pull request 2026-11-25 18:01:36 +00:00
fuzeofficlal commented 2026-11-25 18:02:42 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by fuzeofficlal on 2026-11-25T17:20:16Z.


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.

<!-- greyfinch-sync:Marvisak/VIctory:comment:7169357359 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/1435#issuecomment-7169357359). Originally posted by [fuzeofficlal](https://github.com/fuzeofficlal) on 2026-11-25T17:20:16Z. --- 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

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
Marvisak/VIctory!1434
No description provided.