File tree 4 files changed +43
-0
lines changed
4 files changed +43
-0
lines changed Original file line number Diff line number Diff line change @@ -21,6 +21,7 @@ pub mod fs;
21
21
pub mod io;
22
22
pub mod raw;
23
23
pub mod process;
24
+ pub mod thread;
24
25
25
26
/// A prelude for conveniently writing platform-specific code.
26
27
///
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 {
77
77
c:: Sleep ( super :: dur2timeout ( dur) )
78
78
}
79
79
}
80
+
81
+ pub fn handle ( & self ) -> & Handle { & self . handle }
82
+
83
+ pub fn into_handle ( self ) -> Handle { self . handle }
80
84
}
81
85
82
86
pub mod guard {
Original file line number Diff line number Diff line change @@ -171,6 +171,7 @@ use sys::thread as imp;
171
171
use sys_common:: thread_info;
172
172
use sys_common:: unwind;
173
173
use sys_common:: util;
174
+ use sys_common:: { AsInner , IntoInner } ;
174
175
use time:: Duration ;
175
176
176
177
////////////////////////////////////////////////////////////////////////////////
@@ -621,6 +622,14 @@ impl<T> JoinHandle<T> {
621
622
}
622
623
}
623
624
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
+
624
633
fn _assert_sync_and_send ( ) {
625
634
fn _assert_both < T : Send + Sync > ( ) { }
626
635
_assert_both :: < JoinHandle < ( ) > > ( ) ;
You can’t perform that action at this time.
0 commit comments