Add documentation about lifetimes to thread::scope.#94763
Add documentation about lifetimes to thread::scope.#94763bors merged 1 commit intorust-lang:masterfrom
Conversation
ff781b7 to
09d0111
Compare
|
This looks great -- thank you! Very clear and succinct explanation :) r=me with commits squashed |
c82b279 to
4d56c15
Compare
|
@bors r=Mark-Simulacrum |
|
📌 Commit 4d56c15 has been approved by |
|
@bors rollup |
…s, r=Mark-Simulacrum Add documentation about lifetimes to thread::scope. This resolves the last unresolved question of rust-lang#93203 This was brought up in rust-lang#94559 (comment) r? ``@Mark-Simulacrum``
…s, r=Mark-Simulacrum Add documentation about lifetimes to thread::scope. This resolves the last unresolved question of rust-lang#93203 This was brought up in rust-lang#94559 (comment) r? ```@Mark-Simulacrum```
…s, r=Mark-Simulacrum Add documentation about lifetimes to thread::scope. This resolves the last unresolved question of rust-lang#93203 This was brought up in rust-lang#94559 (comment) r? ````@Mark-Simulacrum````
…askrgr Rollup of 8 pull requests Successful merges: - rust-lang#91804 (Make some `Clone` impls `const`) - rust-lang#92541 (Mention intent of `From` trait in its docs) - rust-lang#93057 (Add Iterator::collect_into) - rust-lang#94739 (Suggest `if let`/`let_else` for refutable pat in `let`) - rust-lang#94754 (Warn users about `||` in let chain expressions) - rust-lang#94763 (Add documentation about lifetimes to thread::scope.) - rust-lang#94768 (Ignore `close_read_wakes_up` test on SGX platform) - rust-lang#94772 (Add miri to the well known conditional compilation names and values) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
danielhenrymantilla
left a comment
There was a problem hiding this comment.
Oh damn that was quickly merged! 😅
| /// The `'scope` lifetime represents the lifetime of the scope itself. | ||
| /// That is: the time during which new scoped threads may be spawned, | ||
| /// and also the time during which they might still be running. | ||
| /// Once this lifetime ends, all scoped threads are joined. |
There was a problem hiding this comment.
| /// Once this lifetime ends, all scoped threads are joined. | |
| /// By design, this lifetime only ends once all the scoped threads have been joined. |
There was a problem hiding this comment.
I care about this one because that's the right ordering: 'scope by very definition, outlives the Scope and Packet instances, so the right property is rather "once the scoped threads are all joined, this lifetime may end", hence my suggestion
| /// That is: the time during which new scoped threads may be spawned, | ||
| /// and also the time during which they might still be running. | ||
| /// Once this lifetime ends, all scoped threads are joined. | ||
| /// This lifetime starts within the `scope` function, before `f` (the argument to `scope`) starts. |
There was a problem hiding this comment.
It's a bit weird to speak of the beginning of a lifetime, it's not really something that comes up in practice or is important. But I guess it's okay for the sake of explaining stuff:
| /// This lifetime starts within the `scope` function, before `f` (the argument to `scope`) starts. | |
| /// This lifetime "starts" within the `scope` function, before `f` (the argument to `scope`) is called. |
| /// and also the time during which they might still be running. | ||
| /// Once this lifetime ends, all scoped threads are joined. | ||
| /// This lifetime starts within the `scope` function, before `f` (the argument to `scope`) starts. | ||
| /// It ends after `f` returns and all scoped threads have been joined, but before `scope` returns. |
There was a problem hiding this comment.
| /// It ends after `f` returns and all scoped threads have been joined, but before `scope` returns. | |
| /// It ends after `f` returns and all scoped threads have been joined, but before `scope` returns[^hrtb]. | |
| /// | |
| /// [^hrtb]: a property of higher-order (`for<'scope>`) lifetimes. |
This resolves the last unresolved question of #93203
This was brought up in #94559 (comment)
r? @Mark-Simulacrum