about summary refs log tree commit diff
path: root/src/libstd/thread
diff options
context:
space:
mode:
authorPeter Atashian <retep998@gmail.com>2015-10-29 16:54:09 -0400
committerPeter Atashian <retep998@gmail.com>2015-12-04 20:09:30 -0500
commit95cdada99a02c5abea4898f46e04f7a271419dac (patch)
treeb8865e6300269b2448f7a8a67db1af802222356d /src/libstd/thread
parentf5150dd9b42d15563e18218910cafc0d4d053250 (diff)
downloadrust-95cdada99a02c5abea4898f46e04f7a271419dac.tar.gz
rust-95cdada99a02c5abea4898f46e04f7a271419dac.zip
AsRawHandle and IntoRawHandle for JoinHandle
This allows users to get the HANDLE of a spawned thread on Windows

Signed-off-by: Peter Atashian <retep998@gmail.com>
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<()>>();