Skip to content

hle: bind queued async work to its original call - #80

Open
smecherucarbarou wants to merge 1 commit into
MiamiGame:mainfrom
smecherucarbarou:hle/async-queued-work-prerequisite
Open

smecherucarbarou wants to merge 1 commit into
MiamiGame:mainfrom
smecherucarbarou:hle/async-queued-work-prerequisite

Conversation

@smecherucarbarou

@smecherucarbarou smecherucarbarou commented Nov 25, 2026 •

Copy link
Copy Markdown
Contributor

What and why

Prerequisite for #42

Queued async work currently resolves its provider by block address when dispatched. After completion and address reuse, old work can invoke or cancel the newer call. A work callback that completes inline can also let its return value complete the replacement call.

Capture the original call through a weak reference in a task-owned context and complete that call directly. Completed or expired calls are skipped. Context ownership ends on dispatch, canceled delivery, rejected submission or queue disposal. Weak ownership avoids a Call/Queue/Task cycle when #42 introduces runtime-owned provider state.

Only crates/xtp-hle/src/modules/xasync.rs changes: 342 changed lines (+331/-11), comprising 51 production (+40/-11) and 291 test (+291/-0). Provider admission/cleanup ordering and completion-queue ownership remain separate contributions. Existing #30/#44 waiting behavior is preserved.

Fixes: none
Depends on: none

Area

xtp-hle: XAsyncSchedule work identity and queued context lifetime.

Tests

  • cargo xtask pr-check passes on my machine
  • New or changed behaviour has tests that need no game files, or I explain below why it cannot
  • Ran on a title: no

Native Windows x64, pinned Rust 1.98.1; base 9b822f58870e351613666129ca5621c6a4955fb7.

  • Before the fix, deterministic tests on unchanged upstream production demonstrated old work invoking the newer provider and an inline completion's work return completing a reused block. Failure logs are retained locally.
  • Final XAsync suite: 20/20 passed, including all upstream tests. 25 consecutive full focused runs: 500 successful executions, including 75 executions of the three new tests.
  • Synthetic cases cover normal/canceled/delayed dispatch, completed calls retained by waiters, callback-driven reuse, rejected submission, immediate/delayed queue disposal and a weak-ownership cycle model. Child execution markers and 20-second deadlines bound the tests; delayed delivery uses a monitor/thread-exit handshake.
  • HLE default and all-features: each passed 204 unit tests and 8 integration tests; 2 unit tests ignored.
  • Complete cargo xtask pr-check --title "hle: bind queued async work to its original call": 5/6 passed (fmt, clippy, clippy-diagnostics, policy, conventions). Workspace tests fail only in the two GPU tests below; the proposed title passes. No contribution commit exists yet, so the commit convention check covered zero commits.
  • Supplemental cargo test --workspace --locked --no-fail-fast: 1,668 passed, 2 failed, 69 ignored, including doctests. Only xtp-gpu --lib failed.
  • The identical failures reproduce on a clean worktree at the same upstream base with an independent build directory: host::twins::tests::a_24_bit_plane_copied_in_a_query_holds_what_the_pass_draws_for_floats (same 1,412 float differences) and host::twins::tests::a_pass_leaves_no_scissor_where_the_title_set_none (intermittent; reproduced in the first repeat). Clean baseline GPU runs: 632 passed/1 failed/14 ignored, then 631 passed/2 failed/14 ignored. No GPU code or assertions were modified.

Provenance

  • I wrote all of this change myself for XTP, or it only moves code already in XTP.
  • Some of it comes from elsewhere. Each source, its licence and the files concerned are listed here, and every licence is compatible with GPL-3.0-or-later:

Original Rust implementation and synthetic fixtures for XTP. Adapted the applicable task-context ownership pattern and callback-reuse regression from the earlier local XTP contribution 0d455a115e9874585099557410aa0deb52fdb883; replaced its strong call capture with a weak reference. No external implementation code was copied or translated. Maintainer scope approval: #42 (comment).

AI assistance: OpenAI Codex implemented the change and tests, reviewed ownership paths, ran validation, and prepared this description. The contributor remains responsible for every line.

Checklist

  • No game data, keys, console SDK code or headers, and nothing that circumvents DRM (asset policy)
  • No code copied from xcl or AnyPS5 (references only: read them to understand, write your own)
  • I agree to license this contribution under GPL-3.0-or-later
  • Title and every commit follow <area>: <summary>; one topic; under 400 changed lines, or the reason is above
  • Docs updated where behaviour, commands or variables changed (README, docs/)

No command, environment-variable or public API changes require additional documentation; the local ownership contract is documented beside the implementation. No commit has been created yet.

@github-actions github-actions Bot added area/hle touches crates/xtp-hle size/M 100 to 399 changed lines labels Nov 25, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/hle touches crates/xtp-hle size/M 100 to 399 changed lines

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant