File tree Expand file tree Collapse file tree 4 files changed +43
-0
lines changed Expand file tree Collapse file tree 4 files changed +43
-0
lines changed Original file line number Diff line number Diff line change @@ -21,6 +21,7 @@ pub mod fs;
2121pub mod io;
2222pub mod raw;
2323pub mod process;
24+ pub mod thread;
2425
2526/// A prelude for conveniently writing platform-specific code.
2627///
Original file line number Diff line number Diff line change 1+ // Copyright 2015 The Rust Project Developers. See the COPYRIGHT
2+ // file at the top-level directory of this distribution and at
3+ // http://rust-lang.org/COPYRIGHT.
4+ //
5+ // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6+ // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7+ // <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8+ // option. This file may not be copied, modified, or distributed
9+ // except according to those terms.
10+
11+ //! Extensions to `std::thread` for Windows.
12+
13+ #![ unstable( feature = "thread_extensions" , issue = "29791" ) ]
14+
15+ use os:: windows:: io:: { RawHandle , AsRawHandle , IntoRawHandle } ;
16+ use thread;
17+ use sys_common:: { AsInner , IntoInner } ;
18+
19+ impl < T > AsRawHandle for thread:: JoinHandle < T > {
20+ fn as_raw_handle ( & self ) -> RawHandle {
21+ self . as_inner ( ) . handle ( ) . raw ( ) as * mut _
22+ }
23+ }
24+
25+ impl < T > IntoRawHandle for thread:: JoinHandle < T > {
26+ fn into_raw_handle ( self ) -> RawHandle {
27+ self . into_inner ( ) . into_handle ( ) . into_raw ( ) as * mut _
28+ }
29+ }
Original file line number Diff line number Diff line change @@ -77,6 +77,10 @@ impl Thread {
7777 c:: Sleep ( super :: dur2timeout ( dur) )
7878 }
7979 }
80+
81+ pub fn handle ( & self ) -> & Handle { & self . handle }
82+
83+ pub fn into_handle ( self ) -> Handle { self . handle }
8084}
8185
8286pub mod guard {
Original file line number Diff line number Diff line change @@ -171,6 +171,7 @@ use sys::thread as imp;
171171use sys_common:: thread_info;
172172use sys_common:: unwind;
173173use sys_common:: util;
174+ use sys_common:: { AsInner , IntoInner } ;
174175use time:: Duration ;
175176
176177////////////////////////////////////////////////////////////////////////////////
@@ -621,6 +622,14 @@ impl<T> JoinHandle<T> {
621622 }
622623}
623624
625+ impl < T > AsInner < imp:: Thread > for JoinHandle < T > {
626+ fn as_inner ( & self ) -> & imp:: Thread { self . 0 . native . as_ref ( ) . unwrap ( ) }
627+ }
628+
629+ impl < T > IntoInner < imp:: Thread > for JoinHandle < T > {
630+ fn into_inner ( self ) -> imp:: Thread { self . 0 . native . unwrap ( ) }
631+ }
632+
624633fn _assert_sync_and_send ( ) {
625634 fn _assert_both < T : Send + Sync > ( ) { }
626635 _assert_both :: < JoinHandle < ( ) > > ( ) ;
You can’t perform that action at this time.
0 commit comments