Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Doc] Add 'static and Send constraints explanations to thread::spawn #41980

Merged
merged 1 commit into from
May 25, 2017

Conversation

gamazeps
Copy link
Contributor

Part of #29378.

Explains why the constraints on the closure and its return value are 'static and Send.

Allows to tick of thread::spawn from the list of things to document in the thread module.

r? @steveklabnik

@gamazeps gamazeps changed the title Add 'static and Send constraints explanations to thread::spawn [Doc] Add 'static and Send constraints explanations to thread::spawn May 13, 2017
/// - The `'static` constraint means that the closure and its return value
/// must have a lifetime of the whole program execution. The reason for this
/// is that threads can `detach` and outlive the lifetime they have been
/// created in.
Copy link
Member

@nagisa nagisa May 14, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thread being able to outlive the scope it has been created in (i.e. detaching) is only an explanation for why closure itself is 'static, and not its return value. The return value has the 'static bound because the return value outlives the thread it is returned from; this is true regardless of whether the thread gets detached or not.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

They are actually linked.

The value a thread returns must outlive the closure, but the fact that the thread can detach implies that the closure must be 'static, since the value must live at least as long as the closure it must then also be 'static

@gamazeps
Copy link
Contributor Author

gamazeps commented May 14, 2017

r? @rust-lang/docs

@GuillaumeGomez
Copy link
Member

Tidy errors:

[00:01:44] tidy error: /checkout/src/libstd/thread/mod.rs:376: trailing whitespace
[00:01:44] tidy error: /checkout/src/libstd/thread/mod.rs:385: trailing whitespace

@gamazeps
Copy link
Contributor Author

Damn, that is valid markdown though...
Fixed

@Mark-Simulacrum Mark-Simulacrum added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label May 14, 2017
@frewsxcv frewsxcv added the A-docs Area: documentation for any part of the project, including the compiler, standard library, and tools label May 14, 2017
@Mark-Simulacrum
Copy link
Member

@steveklabnik This looks read for review.

@steveklabnik
Copy link
Member

@bors: r+ rollup

thanks!

@bors
Copy link
Contributor

bors commented May 24, 2017

📌 Commit 770bd57 has been approved by steveklabnik

Mark-Simulacrum added a commit to Mark-Simulacrum/rust that referenced this pull request May 24, 2017
[Doc] Add `'static` and `Send` constraints explanations to `thread::spawn`

Part of rust-lang#29378.

Explains why the constraints on the closure and its return value are `'static` and `Send`.

Allows to tick of `thread::spawn` from the list of things to document in the `thread` module.

r? @steveklabnik
Mark-Simulacrum added a commit to Mark-Simulacrum/rust that referenced this pull request May 24, 2017
[Doc] Add `'static` and `Send` constraints explanations to `thread::spawn`

Part of rust-lang#29378.

Explains why the constraints on the closure and its return value are `'static` and `Send`.

Allows to tick of `thread::spawn` from the list of things to document in the `thread` module.

r? @steveklabnik
Mark-Simulacrum added a commit to Mark-Simulacrum/rust that referenced this pull request May 24, 2017
[Doc] Add `'static` and `Send` constraints explanations to `thread::spawn`

Part of rust-lang#29378.

Explains why the constraints on the closure and its return value are `'static` and `Send`.

Allows to tick of `thread::spawn` from the list of things to document in the `thread` module.

r? @steveklabnik
bors added a commit that referenced this pull request May 24, 2017
Mark-Simulacrum added a commit to Mark-Simulacrum/rust that referenced this pull request May 25, 2017
[Doc] Add `'static` and `Send` constraints explanations to `thread::spawn`

Part of rust-lang#29378.

Explains why the constraints on the closure and its return value are `'static` and `Send`.

Allows to tick of `thread::spawn` from the list of things to document in the `thread` module.

r? @steveklabnik
Mark-Simulacrum added a commit to Mark-Simulacrum/rust that referenced this pull request May 25, 2017
[Doc] Add `'static` and `Send` constraints explanations to `thread::spawn`

Part of rust-lang#29378.

Explains why the constraints on the closure and its return value are `'static` and `Send`.

Allows to tick of `thread::spawn` from the list of things to document in the `thread` module.

r? @steveklabnik
bors added a commit that referenced this pull request May 25, 2017
@bors bors merged commit 770bd57 into rust-lang:master May 25, 2017
@gamazeps gamazeps deleted the thread-send branch June 14, 2017 10:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-docs Area: documentation for any part of the project, including the compiler, standard library, and tools S-waiting-on-review Status: Awaiting review from the assignee but also interested parties.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants