about summary refs log tree commit diff
path: root/src/libstd/thread
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2015-12-05 20:49:16 +0000
committerbors <bors@rust-lang.org>2015-12-05 20:49:16 +0000
commitaad4e5665e81a3ec998b3648d395d0eb99a7500b (patch)
tree7c9286e32c368bcfb7eb295fd4b35e9eb7285c01 /src/libstd/thread
parent9f715e98925adbf205bccd8a044266c77197db50 (diff)
parent9749a193d629dd723562004879bca3e2d47e25a1 (diff)
downloadrust-aad4e5665e81a3ec998b3648d395d0eb99a7500b.tar.gz
rust-aad4e5665e81a3ec998b3648d395d0eb99a7500b.zip
Auto merge of #30177 - retep998:handling-threads, r=alexcrichton
Allows a `HANDLE` to be extracted from a `JoinHandle` on Windows.
Allows a `pthread_t` to be extracted from a `JoinHandle` everywhere else.

Because https://github.com/rust-lang/rust/pull/29461 was closed.

r? @alexcrichton
Diffstat (limited to 'src/libstd/thread')
-rw-r--r--src/libstd/thread/mod.rs9
1 files changed, 9 insertions, 0 deletions
diff --git a/src/libstd/thread/mod.rs b/src/libstd/thread/mod.rs
index eaa32cdb342..aef47aa5726 100644
--- a/src/libstd/thread/mod.rs
+++ b/src/libstd/thread/mod.rs
@@ -171,6 +171,7 @@ use sys::thread as imp;
 use sys_common::thread_info;
 use sys_common::unwind;
 use sys_common::util;
+use sys_common::{AsInner, IntoInner};
 use time::Duration;
 
 ////////////////////////////////////////////////////////////////////////////////
@@ -621,6 +622,14 @@ impl<T> JoinHandle<T> {
     }
 }
 
+impl<T> AsInner<imp::Thread> for JoinHandle<T> {
+    fn as_inner(&self) -> &imp::Thread { self.0.native.as_ref().unwrap() }
+}
+
+impl<T> IntoInner<imp::Thread> for JoinHandle<T> {
+    fn into_inner(self) -> imp::Thread { self.0.native.unwrap() }
+}
+
 fn _assert_sync_and_send() {
     fn _assert_both<T: Send + Sync>() {}
     _assert_both::<JoinHandle<()>>();