-
Notifications
You must be signed in to change notification settings - Fork 13.1k
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] Improve the thread::park and thread::unpark documentation #41809
Conversation
- Adds an explanantion of what `park` does in the `unpark` documentation. - Adds a link to the module doc.
(rust_highfive has picked a reviewer for you, use r? to override) |
src/libstd/thread/mod.rs
Outdated
/// The semantics of this function are equivalent to `park()` except that the | ||
/// thread will be blocked for roughly no longer than `ms`. This method | ||
/// should not be used for precise timing due to anomalies such as | ||
/// The semantics of this function are equivalent to [`park()`][[park] except |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Too many [
here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
thanks :)
src/libstd/thread/mod.rs
Outdated
/// The semantics of this function are equivalent to `park()` except that the | ||
/// thread will be blocked for roughly no longer than `dur`. This method | ||
/// should not be used for precise timing due to anomalies such as | ||
/// The semantics of this function are equivalent to [`park()`][[park] except |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ditto.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ditto. 👍
src/libstd/thread/mod.rs
Outdated
/// | ||
/// [unpark]: struct.Thread.html#method.unpark | ||
/// In other words, each [`Thread`] acts a bit like a spinlock that can be | ||
/// lockend and unlocked using `park` and `unpark`. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
locked
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So much typos, the shame is strong in me.
src/libstd/thread/mod.rs
Outdated
/// # park and unpark | ||
/// | ||
/// Every thread is equipped with some basic low-level blocking support, via the | ||
/// [`thread::park`][`park`] function and [`thread::Thread::unpark()`][`unpark`] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't know if you are allowed to use the ()
here 😄
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It is used elsewhre and I checked that they worked, so I think I am allowed to do that.
I can be removed if you want to though.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
currently, the policy is to remove the ()
for method/function names in docs (see also #40456), though it's not a huge deal
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It shall be done then :p
src/libstd/thread/mod.rs
Outdated
@@ -591,11 +604,10 @@ pub fn park() { | |||
/// preemption or platform differences that may not cause the maximum | |||
/// amount of time waited to be precisely `ms` long. | |||
/// | |||
/// See the [module documentation][thread] for more detail. | |||
/// See the [park documentation][park] for more detail. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The link should point to [`park`]
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Indeed, missed that one.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this still needs to be fixed
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done :)
Part of rust-lang#29378 - Moves the module documentation into `park`. - Add the same example as the one from `unpark` to `park`.
/// .unwrap(); | ||
/// | ||
/// // Let some time pass for the thread to be spawned. | ||
/// thread::sleep(Duration::from_millis(10)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As per the failures on Travis (scroll near the bottom), you'll need to import Duration
into scope here
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
(this has been addressed)
All comments are addressed (sory for the delay I'm following the French election at the same time :p) |
Looks like one travis job failed due to network failure on checking out the PR, logged here #40474 (comment) and restarted the travis build. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
r=me after that link gets fixed
src/libstd/thread/mod.rs
Outdated
@@ -591,11 +604,10 @@ pub fn park() { | |||
/// preemption or platform differences that may not cause the maximum | |||
/// amount of time waited to be precisely `ms` long. | |||
/// | |||
/// See the [module documentation][thread] for more detail. | |||
/// See the [park documentation][park] for more detail. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this still needs to be fixed
/// .unwrap(); | ||
/// | ||
/// // Let some time pass for the thread to be spawned. | ||
/// thread::sleep(Duration::from_millis(10)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
(this has been addressed)
[Doc] improve `thread::Thread` and `thread::Builder` documentations Part of #29378 - Adds information about the stack_size when using `Builder`. This might be considered too low level, but I assume that if someone wants to create their own builder instead of using `thread::spawn` they may be interested in that info. - Updates the `thread::Thread` structure doc, mostly by explaining how to get one, the previous example was removed because it was not related to `thread::Thread`, but rather to `thread::Builder::name`. Not much is present there, mostly because this API is not often used (the only method that seems useful is `unpark`, which is documented in #41809).
@bors r=steveklabnik rollup |
📌 Commit afe74c3 has been approved by |
[DOC] Improve the thread::park and thread::unpark documentation Part of rust-lang#29378 . Takes care of the documentation for `park`, `park_duration` and also improves the `unpark` example. - `park should` have its module documentation inlined here, and cleaned up. - `park_timeout` could use links to `park`.
Link is fixed I think :) |
[DOC] Improve the thread::park and thread::unpark documentation Part of rust-lang#29378 . Takes care of the documentation for `park`, `park_duration` and also improves the `unpark` example. - `park should` have its module documentation inlined here, and cleaned up. - `park_timeout` could use links to `park`.
Yep, looks fixed! Just waiting to be tested and merged by our infrastructure |
[DOC] Improve the thread::park and thread::unpark documentation Part of rust-lang#29378 . Takes care of the documentation for `park`, `park_duration` and also improves the `unpark` example. - `park should` have its module documentation inlined here, and cleaned up. - `park_timeout` could use links to `park`.
Part of #29378 .
Takes care of the documentation for
park
,park_duration
and also improves theunpark
example.park should
have its module documentation inlined here, and cleaned up.park_timeout
could use links topark
.