Task queues: terminating cancels delayed callbacks before the termination callback #53
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/54"
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 ivall/xcl. Originally posted by gefydev on 2026-11-22T22:46:32Z.
XTaskQueueTerminate(taskqueue.rs) cancels the callbacks queued on the queue's ports, but not delayed callbacks (XTaskQueueSubmitDelayedCallback, also used byXAsyncSchedulewith a delay) that are still waiting in the timer heap. Those only count ininflightonce they are due. So the wait inTerminatedoesn't hold the termination callback for them: it runs first, and the delayed callback runs later, canceled, up to its full delay after the queue was terminated. A title often frees in the termination callback what it passed as those callbacks' context.libHttpClient moves a terminating port's pending delayed entries to its active list (
CancelPendingEntries(cxt, true)inTaskQueuePortImpl::Terminate), so they are invoked canceled before termination completes.Terminatenow takes the queue's entries out of the timer heap and invokes them canceled before the termination callback, the same way it already handles the port items. Delayed callbacks of other queues stay in the heap.Validation
terminate_cancels_delayed_callbacks_before_its_own_callback: a 60 s delayed callback, thenTerminate(wait = true)with a termination callback. Onmainonly["terminated"]is recorded; with the change it is["delayed, canceled", "terminated"].cargo test -p xcl --lib: 340 passed, 0 failed, on Windows GNU under Wine.Imported from ivall/xcl. Originally posted by ivall on 2026-11-23T09:45:13Z.
Merged (
2e000cb). The module comment oftaskqueue.rsnow describes termination as it is after this and #57 (e38cb65).Tested on Windows 11 (RX 9070):
cargo test --workspacegreen (lib 351, e2e), and a 45 s Unicorn Overlord run on the release build (VFS hooks active, ~60 fps, clean exit). Thanks!