-
Notifications
You must be signed in to change notification settings - Fork 12.8k
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
AsRawHandle and IntoRawHandle for JoinHandle #29461
Conversation
r? @brson (rust_highfive has picked a reviewer for you, use r? to override) |
Looks good to me! I would like to ensure feature parity between Unix and Windows, however, so I think that this would want to land in tandem with a lowering from |
There's no |
Yeah, although I wouldn't add a |
7ab5316
to
2cae9a3
Compare
Added unix implementation. |
|
||
pub fn id(&self) -> &libc::pthread_t { &self.id } | ||
|
||
pub fn into_id(self) -> libc::pthread_t { self.id } |
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 think that this will want to cancel the destructor via mem::forget
Thanks! I'll flag this with T-libs so it comes up during triage. |
This allows users to get the HANDLE of a spawned thread on Windows Signed-off-by: Peter Atashian <[email protected]>
7ea8c35
to
bdbfe0c
Compare
Addressed comments. Travis seems like it is way behind. |
bdbfe0c
to
8118ab9
Compare
Signed-off-by: Peter Atashian <[email protected]>
8118ab9
to
88d7df6
Compare
@@ -15,6 +15,8 @@ | |||
#[stable(feature = "raw_ext", since = "1.1.0")] pub type uid_t = u32; | |||
#[stable(feature = "raw_ext", since = "1.1.0")] pub type gid_t = u32; | |||
#[stable(feature = "raw_ext", since = "1.1.0")] pub type pid_t = i32; | |||
#[unstable(feature = "pthread_t", issue = "0")] | |||
pub type pthread_t = usize; |
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 is actually a little more involved, taking a look at the definition in liblibc:
$ git grep 'type pthread_t'
src/unix/bsd/mod.rs:pub type pthread_t = ::uintptr_t;
src/unix/notbsd/android/mod.rs:pub type pthread_t = c_long;
src/unix/notbsd/linux/mod.rs:pub type pthread_t = c_ulong;
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.
Are c_long
and c_ulong
ever a different size than usize
on Linux and Android?
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.
In terms of what actually happens they're all the same size (I believe), but I think it's best to ensure that they're the same definition so the libstd pthread_t is interoperable with the libc pthread_t.
The libs team discussed this today during triage and we were definitely ok with the Windows impls but there are some other possible questions around the Unix ones (which I've now filed in the tracking issue). If you could update the tracking issue references then we felt this was good to go because the Unix aspects are still unstable. |
Closing due to inactivity, but feel free to resubmit with comments addressed! |
Allows a `HANDLE` to be extracted from a `JoinHandle` on Windows. Allows a `pthread_t` to be extracted from a `JoinHandle` everywhere else. Because #29461 was closed. r? @alexcrichton
This allows users to get the HANDLE of a spawned thread on Windows.
Ditto with pthread_t and non-Windows.