-
Notifications
You must be signed in to change notification settings - Fork 13.2k
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
Partially implement thread scheduling attributes API proposal #101222
Partially implement thread scheduling attributes API proposal #101222
Conversation
(rust-highfive has picked a reviewer for you, use r? to override) |
|
@@ -97,6 +102,9 @@ impl Thread { | |||
} | |||
} | |||
|
|||
pub type Priority = (); |
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.
These should be structs instead of type definitions in case this is implemented for the target in the future.
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.
Since this is a private type, I think it should be possible to change its type freely without any consequences to user code (alias or otherwise). However if it was re-exported as pub
(per your other comment) then I agree it would be better as struct Priority(())
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.
Ah yeah, this is sys and not actually public
@@ -346,6 +361,18 @@ impl Builder { | |||
self | |||
} | |||
|
|||
#[unstable(feature = "thread_scheduling", issue = "none")] | |||
pub fn priority(mut self, priority: Priority) -> Builder { |
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.
Why can't this take in imp::Priority
?
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 could only do so if imp::Priority
was also re-exported (otherwise it's a private type in a public interface).
I couldn't find many (if any) instances of re-exporting things from sys
, although in this case it would really be a re-export of stuff from os
which is already public, so maybe it would be fine? Even so, I think it would mean that Priority
+ Affinity
would have do be documented in every variation of sys::*
rather than just once in the public interface.
Also, for those unsupported platforms that just use ()
my thinking was it would make more sense to use an "unconstructible" public type. I suppose re-exporting a struct Priority(())
would achieve the same.
@joshtriplett have you (or any other libs team) had any chance to look at this and see if it meets your expectations from the discussion in rust-lang/libs-team#71 ? If not, are there other changes or tests/use-cases I could add to prove out this API further to hopefully move along the ACP? Thanks! Also tried to ping @rust3ds/active to look over the docs I added / provide any inputs, but I guess Github doesn't let you cross-org ping like that. |
This comment has been minimized.
This comment has been minimized.
The job Click to see the possible cause of the failure (guessed by this bot)
|
☔ The latest upstream changes (presumably #106981) made this pull request unmergeable. Please resolve the merge conflicts. |
This PR is a sketch of the standard library API proposed in rust-lang/libs-team#71 (comment)
It most likely doesn't compile on all platforms, and it won't work correctly on Linux without added
libc
support for the corresponding pthread APIs, but I think this works as a proof-of-concept to create a portable-enough API that abstracts over the OS-specific details.Many of the changes are taken from #98514 but the public API is somewhat different. See the libs-team discussion linked above for more details.
CC @AzureMarker @Meziu