File tree 4 files changed +41
-0
lines changed 4 files changed +41
-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
+ use os:: windows:: io:: { RawHandle , AsRawHandle , IntoRawHandle } ;
14
+ use thread;
15
+ use sys_common:: { AsInner , IntoInner } ;
16
+
17
+ impl < T > AsRawHandle for thread:: JoinHandle < T > {
18
+ fn as_raw_handle ( & self ) -> RawHandle {
19
+ self . as_inner ( ) . handle ( ) . raw ( ) as * mut _
20
+ }
21
+ }
22
+
23
+ impl < T > IntoRawHandle for thread:: JoinHandle < T > {
24
+ fn into_raw_handle ( self ) -> RawHandle {
25
+ self . into_inner ( ) . into_handle ( ) . into_raw ( ) as * mut _
26
+ }
27
+ }
Original file line number Diff line number Diff line change @@ -78,6 +78,10 @@ impl Thread {
78
78
c:: Sleep ( super :: dur2timeout ( dur) )
79
79
}
80
80
}
81
+
82
+ pub fn handle ( & self ) -> & Handle { & self . handle }
83
+
84
+ pub fn into_handle ( self ) -> Handle { self . handle }
81
85
}
82
86
83
87
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
////////////////////////////////////////////////////////////////////////////////
@@ -619,6 +620,14 @@ impl<T> JoinHandle<T> {
619
620
}
620
621
}
621
622
623
+ impl < T > AsInner < imp:: Thread > for JoinHandle < T > {
624
+ fn as_inner ( & self ) -> & imp:: Thread { self . 0 . native . as_ref ( ) . unwrap ( ) }
625
+ }
626
+
627
+ impl < T > IntoInner < imp:: Thread > for JoinHandle < T > {
628
+ fn into_inner ( self ) -> imp:: Thread { self . 0 . native . unwrap ( ) }
629
+ }
630
+
622
631
fn _assert_sync_and_send ( ) {
623
632
fn _assert_both < T : Send + Sync > ( ) { }
624
633
_assert_both :: < JoinHandle < ( ) > > ( ) ;
You can’t perform that action at this time.
0 commit comments