Skip to content

Task queues: a terminated queue takes no new work - #57

Merged
ivall merged 1 commit into
xcl-dev:mainfrom
gefydev:taskqueue-submit-after-terminate
Nov 23, 2026
Merged

ivall merged 1 commit into
xcl-dev:mainfrom
gefydev:taskqueue-submit-after-terminate

Conversation

@gefydev

@gefydev gefydev commented Nov 22, 2026

Copy link
Copy Markdown
Member

XTaskQueueSubmitCallback, XTaskQueueSubmitDelayedCallback and XTaskQueueRegisterWaiter accept work on a queue after XTaskQueueTerminate. That work then runs canceled, and a delayed callback runs after the termination callback has already told the title that the queue is done: a title that frees its context there gets a callback on freed memory. This happens, for example, with a callback that reschedules itself from its own canceled invocation during termination.

libHttpClient rejects new work on a terminating or terminated port with E_ABORT (TaskQueuePortImpl::VerifyNotTerminated, called from QueueItem and RegisterWaitHandle). The three functions now do the same.

E_ABORT_QUEUE_TERMINATED is removed: it was unused, and its value (0x80040001) is not E_ABORT (0x80004004).

Complements #54 (delayed callbacks already pending when the queue terminates); no conflicts between the two.

Validation

  • New test a_terminated_queue_takes_no_new_work. On main the first submit after Terminate returns S_OK instead of E_ABORT.
  • cargo test -p xcl --lib: 344 passed, 0 failed, on Windows GNU under Wine.

XTaskQueueSubmitCallback, XTaskQueueSubmitDelayedCallback and
XTaskQueueRegisterWaiter accepted work on a terminated queue. Such work
ran canceled, and a delayed callback ran after the termination callback
had already told the title the queue was done. They now return E_ABORT,
as libHttpClient's VerifyNotTerminated does.

E_ABORT_QUEUE_TERMINATED (unused, and not E_ABORT's value) is removed.
@ivall
ivall merged commit eb8ed07 into xcl-dev:main Nov 23, 2026
ivall added a commit that referenced this pull request Nov 23, 2026
Like XTaskQueueSubmitDelayedCallback since #57 (libHttpClient schedules through it): E_ABORT,
so XAsyncRun / XCL's own operations on a terminated queue fail through the block (#56) and
their work never runs. Test async_work_on_a_terminated_queue_is_aborted; the task queue
module comment follows #54 / #57.
@ivall

ivall commented Nov 23, 2026

Copy link
Copy Markdown
Collaborator

Merged (eb8ed07). Extended to XAsyncSchedule in e38cb65 (it submitted through the internal submit_delayed, past the new check).

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!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants