Documented thread hooks on panics and errors of thread spawning functions.#149927
Documented thread hooks on panics and errors of thread spawning functions.#149927AhoyISki wants to merge 6 commits intorust-lang:mainfrom
Conversation
… spawning functions.
library/std/src/thread/builder.rs
Outdated
| /// | ||
| /// Panics if a thread name was set and it contained null bytes. | ||
| /// | ||
| /// Unlike the [`spawn`] free function, if it panics for this reason, the |
There was a problem hiding this comment.
Unlike the
spawnfree function
thread::spawn calls Builder::spawn internally, so this is misleading – it's just that thread::spawn doesn't set a thread name and thus will never panic for this reason.
library/std/src/thread/functions.rs
Outdated
| /// Panics if the OS fails to create a thread; use [`Builder::spawn`] to recover | ||
| /// from such errors. | ||
| /// | ||
| /// Additionally, if hooks were added via [`add_spawn_hook`], they will still be |
There was a problem hiding this comment.
"Additionally" isn't a good phrasing here, this isn't describing another panicking case, but rather adding more detail to the previous sentence. How about just combining the two paragraphs without any conjunction? Like
Panics if the OS fails to create a thread; use
Builder::spawnto recover from such errors. If hooks...
library/std/src/thread/scoped.rs
Outdated
| /// Panics if the OS fails to create a thread; use [`Builder::spawn_scoped`] | ||
| /// to recover from such errors. | ||
| /// | ||
| /// like the free [`spawn`] function, if hooks were added via [`add_spawn_hook`], |
There was a problem hiding this comment.
This should then match the thread::spawn documentation exactly.
library/std/src/thread/scoped.rs
Outdated
| /// Panics if a thread name was set and it contained null bytes. | ||
| /// | ||
| /// Unlike with [`Scope::spawn`], if it panics for this reason, the hooks | ||
| /// added by [`add_spawn_hook`] will _not_ be called. |
|
Reminder, once the PR becomes ready for a review, use |
Reword documentation for clarity regarding spawn hooks.
Removed unused documentation reference to `spawn` in scoped thread.
|
@rustbot ready |
|
r? libs-api |
|
☔ The latest upstream changes (presumably #150559) made this pull request unmergeable. Please resolve the merge conflicts. |
|
This PR was rebased onto a different main commit. Here's a range-diff highlighting what actually changed. Rebasing is a normal part of keeping PRs up to date, so no action is needed—this note is just to help reviewers. |
|
|
The job Click to see the possible cause of the failure (guessed by this bot) |
|
@AhoyISki I would love to see the thread hooks feature stabilized. Does this need rebasing by by you before this can move forward? |
|
@BrynCooke I guess I need to do the steps above, huh? I'll try to do that later today |
This PR solves a concern regarding #132951
Considering that the feature has been on nightly for over a year, I would also like to see it stabilized, since no one has voiced any concerns about its current implementation.