feat: finalize libuv thread#14037
Draft
algebraic-dev wants to merge 3 commits into
Draft
Conversation
This PR moves task-manager teardown out of the shell's RAII `scoped_task_manager` and into the runtime's `finalize()`, where it now runs after a new `finalize_libuv` hook so that libuv is finalized before the task-manager worker pool is drained. The shell and the compiler-generated `main` already initialize the task manager explicitly (they need the thread count, which is only known after option parsing), so `scoped_task_manager` is removed and the shell relies on the `initializer` destructor for finalization. `finalize_libuv` is currently a documented no-op stub matching the prior behaviour where libuv was never finalized; only the ordering is wired up, leaving a real libuv shutdown to be slotted in ahead of the drain. The `-j0` (no task manager) semantics are unchanged. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Collaborator
|
Reference manual CI status:
|
|
Mathlib CI status (docs):
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
his PR finalizes all the handles, destroys all objects, and destroys the lthread that runs event_loop before task_manager is null. It also adds safeguards so we can check if the libuv thread died when a Task accesses libuv during the interval in which it is finalizing.
As a future PR, as the code gets more and more complicated, I want to make a PR adding a libuv_loop class and RAII safety guards to lock and unlock libuv.