File tree Expand file tree Collapse file tree 1 file changed +6
-7
lines changed Expand file tree Collapse file tree 1 file changed +6
-7
lines changed Original file line number Diff line number Diff line change @@ -69,37 +69,36 @@ impl<T> EventSource for Park<'_, T> {
69
69
}
70
70
}
71
71
72
- const _: ( ) = assert ! ( std:: mem:: size_of:: <Thread >( ) == std:: mem:: size_of:: <usize >( ) ) ;
73
72
struct Blocker {
74
73
handle : NonZeroUsize ,
75
74
}
76
75
77
76
impl Blocker {
78
77
#[ inline]
79
78
fn new_coroutine ( co : CoroutineImpl ) -> Self {
80
- let handle: NonZeroUsize = unsafe { std :: mem :: transmute ( co) } ;
79
+ let handle = NonZeroUsize :: new ( co. into_raw ( ) as usize ) . unwrap ( ) ;
81
80
Blocker { handle }
82
81
}
83
82
84
83
#[ inline]
85
84
fn new_thread ( thread : Thread ) -> Self {
86
- let mut handle: NonZeroUsize = unsafe { std :: mem :: transmute ( thread) } ;
85
+ let mut handle = NonZeroUsize :: new ( Box :: into_raw ( Box :: new ( thread) ) as usize ) . unwrap ( ) ;
87
86
handle |= 1 ;
88
87
Blocker { handle }
89
88
}
90
89
91
90
#[ inline]
92
91
fn into_coroutine ( self ) -> CoroutineImpl {
93
- let co: CoroutineImpl = unsafe { std :: mem :: transmute ( self . handle ) } ;
92
+ let co = unsafe { CoroutineImpl :: from_raw ( self . handle . get ( ) as * mut _ ) } ;
94
93
std:: mem:: forget ( self ) ;
95
94
co
96
95
}
97
96
98
97
#[ inline]
99
98
fn into_thread ( self ) -> Thread {
100
- let thread: Thread = unsafe { std :: mem :: transmute ( self . handle . get ( ) & !1 ) } ;
99
+ let thread: Box < Thread > = unsafe { Box :: from_raw ( ( self . handle . get ( ) & !1 ) as * mut _ ) } ;
101
100
std:: mem:: forget ( self ) ;
102
- thread
101
+ * thread
103
102
}
104
103
105
104
#[ inline]
@@ -120,7 +119,7 @@ impl Drop for Blocker {
120
119
// let co = self.into_coroutine();
121
120
unreachable ! ( )
122
121
} else {
123
- let _thread: Thread = unsafe { std :: mem :: transmute ( self . handle . get ( ) & !1 ) } ;
122
+ let _thread: Box < Thread > = unsafe { Box :: from_raw ( ( self . handle . get ( ) & !1 ) as * mut _ ) } ;
124
123
}
125
124
}
126
125
}
You can’t perform that action at this time.
0 commit comments