XTaskQueue: a dispatch serves every port, not only manual ones #2614
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/2616"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Imported from Marvisak/VIctory. Originally posted by F1reworks10 on 2026-11-25T16:56:33Z.
XTaskQueueDispatchreturnedfalseimmediately for thread-pool, serialized and immediate ports. It ran nothing and did not wait out its timeout.The GDK documentation for XTaskQueueDispatch says:
timeoutInMs: "The number of milliseconds to wait for work to arrive before returning false."The public reference implementation behaves the same way. In libHttpClient's
TaskQueue.cpp,TaskQueuePortImpl::Dispatchtakes one entry from the port's queue whatever the port's mode, and waits up to the timeout for one.On main this has two consequences:
Change (
crates/victory-hle/src/modules/xasync.rs)XTaskQueueDispatchtakes the first one on the calling thread whatever the mode.false, as the reference does.run_first). That turn runs the port's first callback unless a dispatch already took it, so each callback still runs exactly once.XTaskQueueTerminatenow also cancels thread-pool callbacks that are still waiting for a pool thread. This matches its documentation: "All callbacks for both ports will be invoked with their canceled parameter set to true". On main the pool ran them uncancelled.Tests
dispatch_runs_a_serialized_ports_callback_on_the_calling_thread: fails on main, because the dispatch returnsfalseimmediately.dispatch_waits_its_timeout_on_a_thread_pool_port: fails on main, because the dispatch returns at once instead of after 200 ms.thread_pool_callbacks_run_once_wherever_they_run: checks that no callback runs twice when dispatches and the pool compete for them.cargo test -p victory-hlepasses (149 tests). Clippy is clean with-D warnings, with and without--all-features. Tested on Windows 11 with an RTX 3060 Ti.🤖 Generated with Claude Code
Imported from Marvisak/VIctory. Originally posted by DrDarkDK on 2026-11-25T17:00:27Z.
Review: CHANGES_REQUESTED
This extends the shared-port cancellation bug from #403 to thread-pool ports. On the base, those callbacks go straight to
POOL. With this PR they enter the sharedPort::tasksdeque, whichXTaskQueueTerminatedrains in full. If queue A and composite queue B share a thread-pool port, terminating B can now invoke A’s queued callback withcanceled = true.Could we reuse #403’s approach of tracking which queue owns each callback and add a regression test for shared thread-pool ports? libHttpClient also limits cancellation to the terminating queue’s port context. Reference implementation
Static review only.
AI-assisted with Codex.
Imported from Marvisak/VIctory. Originally posted by kotekompotek on 2026-11-25T17:45:04Z.
Reviewed: moving ThreadPool onto the per-port task list plus a pool 'turn' that pops the front keeps FIFO order while letting
XTaskQueueDispatchserve any mode (per the docs, dispatch works on any dispatch mode). Turns are 1:1 with submissions, so a dispatch that drained the queue leaves a turn that harmlessly finds it empty; the extra Arc raw-ptr round trip is reclaimed inrun_first. CI green.Imported from Marvisak/VIctory. Originally posted by Marvisak on 2026-11-25T22:15:22Z.
Automated triage for the maintainers.
This PR no longer merges cleanly into
main(f3578e3). The conflict is incrates/victory-hle/src/modules/xasync.rs. It will be reviewed once it is rebased onto currentmain.Generated by Claude Code
Imported from Marvisak/VIctory. Originally posted by cloph-dsp on 2026-11-27T14:33:25Z.
Independent CPU-only verification on Windows / Rust 1.100.0 / MSVC.
55da126c87b47587c812518f352d757287f84f56, merge base63bcca43c6a00a758510398fa43096ce7e4f7df0.cargo test --locked -p victory-hle --lib -- modules::xasync::tests::dispatch_runs_a_serialized_ports_callback_on_the_calling_thread --exact --test-threads=1 --quiettest result: ok. 1 passed; 0 failed; 0 ignored; 0 measured; 154 filtered out, exit 0.git grep -F -c dispatch_runs_a_serialized_ports_callback_on_the_calling_thread 63bcca43 -- .→ exit 1 / 0 hits (test genuinely new); present on PR head.git diff --check 63bcca43 HEAD→ exit 0.Imported from Marvisak/VIctory. Originally posted by DrDarkDK on 2026-11-27T20:24:34Z.
Review: CHANGES_REQUESTED
I reproduced the shared-port cancellation on the rebased head
55da126. I submitted queue A’s callback to a thread-pool port shared with composite queue B, held the pool turn pending, then terminated B.On base
63bcca4, A’s callback stayed pending and ran uncanceled when I executed the pool turn. On this head, terminating B ran A’s callback immediately withcanceled = true, and the pool turn found nothing left to run.Could termination cancel only callbacks owned by the terminating queue, with this shared thread-pool case as the regression? #403 shows the queue-ownership approach.
Tested on Windows with Rust 1.100.0 MSVC in a standalone harness using the queue code from both revisions. The harness controlled the worker turn. No game or full crate run.
AI-assisted with Codex.
View command line instructions
Checkout
From your project repository, check out a new branch and test the changes.Merge
Merge the changes and update on Forgejo.Warning: The "Autodetect manual merge" setting is not enabled for this repository, you will have to mark this pull request as manually merged afterwards.