-
Notifications
You must be signed in to change notification settings - Fork 13.3k
Implement Partial{,Eq} for JoinHandle & os::Thread #29457
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
Conversation
r? @aturon (rust_highfive has picked a reviewer for you, use r? to override) |
While the underlying implementations may be useful, I'm not sure why we'd want to implement |
@alexcrichton putting it into I’d argue it has similar usefulness as implementing |
@@ -106,3 +107,13 @@ impl RawHandle { | |||
Ok(Handle::new(ret)) | |||
} | |||
} | |||
|
|||
impl PartialEq<RawHandle> for RawHandle { |
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 believe the parameter on PartialEq
is defaulted to Self
so this and the ones around I believe can be left off.
Hm I guess so, yeah, makes sense. I'm gonna tag with T-libs so this comes up during triage, thanks for the PR @nagisa! |
CompareObjectHandles is W10+, so can’t be used. |
Add ThreadId for comparing threads This adds the capability to store and compare threads with the current calling thread via a new struct, `std::thread::ThreadId`. Addresses the need outlined in issue #21507. This avoids the need to add any special checks to the existing thread structs and does not rely on the system to provide an identifier for a thread, since it seems that this approach is unreliable and undesirable. Instead, this simply uses a lazily-created, thread-local `usize` whose value is copied from a global atomic counter. The code should be simple enough that it should be as much reliable as the `#[thread_local]` attribute it uses (however much that is). `ThreadId`s can be compared directly for equality and have copy semantics. Also see these other attempts: - #29457 - #29448 - #29447 And this in the RFC repo: rust-lang/rfcs#1435
Windows implementation is untested.
Complements the
Eq for Thread
PR.