XAsync: cancellation is the provider's to do #53

Manually merged
github merged 1 commit from gh-pr/53/head into gh-pr/53/base 2026-11-26 04:06:44 +00:00
Owner

@⁠gefydev on GitHub · 2026-11-22 22:41 UTC · original
gefydev:xasync-cancel-to-provider → main · +69 −1 · 1 files · 1 commits · merged 2026-11-23 09:44 UTC

XAsyncCancel (xasync.rs) calls the provider with XAsyncOp::Cancel and then completes the block with E_ABORT itself. libHttpClient's XAsyncCancel (Source/Task/AsyncLib.cpp) only calls the provider. A provider that supports cancelling completes with E_ABORT, now or later. One that doesn't, like the provider behind XAsyncRun, which ignores Cancel, runs to its normal end.

Forcing the completion has two effects in XCL's fallback (no Gaming Services):

  • An XAsyncRun or a provider that ignores Cancel ends with E_ABORT, and work that hasn't started yet never runs.
  • E_ABORT has no payload, so XAsyncComplete runs the provider's Cleanup right away, even if its DoWork is still running on the queue. For XCL's own operations (begin_with), that Cleanup frees the Payload. The running work then writes its result into it when it returns (*p.result.lock() = Some(r) in payload_provider).

XAsyncCancel now only calls the provider. XCL's payload_provider already ignores Cancel, so XCL's own operations finish normally, as XAsyncRun does in libHttpClient.

Validation

  • cancel_is_the_providers_to_do: a provider that ignores Cancel stays pending and completes normally; one that completes in Cancel ends with E_ABORT. The first half fails on main.
  • cancel_lets_running_work_finish: cancels a begin_with operation while its work is running, then reads the work's result. On main, the status is E_ABORT right after the cancel.
  • cargo test -p xcl --lib: 341 passed, 0 failed, on Windows GNU under Wine.
**@⁠gefydev** on GitHub · 2026-11-22 22:41 UTC · [original](https://github.com/xcl-dev/xcl/pull/53) `gefydev:xasync-cancel-to-provider` → `main` · +69 −1 · 1 files · 1 commits · merged 2026-11-23 09:44 UTC `XAsyncCancel` (`xasync.rs`) calls the provider with `XAsyncOp::Cancel` and then completes the block with `E_ABORT` itself. libHttpClient's `XAsyncCancel` (`Source/Task/AsyncLib.cpp`) only calls the provider. A provider that supports cancelling completes with `E_ABORT`, now or later. One that doesn't, like the provider behind `XAsyncRun`, which ignores `Cancel`, runs to its normal end. Forcing the completion has two effects in XCL's fallback (no Gaming Services): - An `XAsyncRun` or a provider that ignores `Cancel` ends with `E_ABORT`, and work that hasn't started yet never runs. - `E_ABORT` has no payload, so `XAsyncComplete` runs the provider's `Cleanup` right away, even if its `DoWork` is still running on the queue. For XCL's own operations (`begin_with`), that `Cleanup` frees the `Payload`. The running work then writes its result into it when it returns (`*p.result.lock() = Some(r)` in `payload_provider`). `XAsyncCancel` now only calls the provider. XCL's `payload_provider` already ignores `Cancel`, so XCL's own operations finish normally, as `XAsyncRun` does in libHttpClient. ## Validation - `cancel_is_the_providers_to_do`: a provider that ignores `Cancel` stays pending and completes normally; one that completes in `Cancel` ends with `E_ABORT`. The first half fails on `main`. - `cancel_lets_running_work_finish`: cancels a `begin_with` operation while its work is running, then reads the work's result. On `main`, the status is `E_ABORT` right after the cancel. - `cargo test -p xcl --lib`: 341 passed, 0 failed, on Windows GNU under Wine.
XAsyncCancel called the provider's Cancel and then completed the block
with E_ABORT itself. libHttpClient's XAsyncCancel only calls the
provider: one that supports cancelling completes with E_ABORT, one that
does not (XAsyncRun's) runs to its normal end.

Completing in XAsyncCancel also ran the provider's cleanup at once
(E_ABORT has no payload) while its DoWork could still be running. For
XCL's own operations (begin_with) that cleanup frees the Payload the
running work writes its result into when it returns.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 04:06:43 +00:00
github manually merged commit 48aabc1706 into gh-pr/53/base 2026-11-26 04:06:44 +00:00
Author
Owner

@⁠ivall on GitHub · 2026-11-23 09:45 UTC · original

Merged in 848e740 (merge a963568). Matches libHttpClient's XAsyncCancel; the payload freed under a running DoWork was a real hazard in the fallback path.

Tested on Windows 11 (RX 9070): cargo test --workspace green (lib 351, e2e), and a 45 s Unicorn Overlord run on the release build (VFS hooks active, ~60 fps, clean exit). Thanks!

**@⁠ivall** on GitHub · 2026-11-23 09:45 UTC · [original](https://github.com/xcl-dev/xcl/pull/53#issuecomment-7097052019) Merged in 848e740 (merge a963568). Matches libHttpClient's `XAsyncCancel`; the payload freed under a running DoWork was a real hazard in the fallback path. Tested on Windows 11 (RX 9070): `cargo test --workspace` green (lib 351, e2e), and a 45 s Unicorn Overlord run on the release build (VFS hooks active, ~60 fps, clean exit). Thanks!
This discussion has been locked. Commenting is limited to contributors.
No description provided.