@@ -6,29 +6,36 @@ pub(crate) mod thread {
6
6
use std:: thread:: Thread ;
7
7
use core:: { task, mem} ;
8
8
9
- const VTABLE : task:: RawWakerVTable = task:: RawWakerVTable :: new ( clone, action , action , on_drop) ;
9
+ const VTABLE : task:: RawWakerVTable = task:: RawWakerVTable :: new ( clone, wake , wake_by_ref , on_drop) ;
10
10
11
11
unsafe fn on_drop ( thread : * const ( ) ) {
12
- let thread: Thread = mem :: transmute ( thread) ;
12
+ let thread = Box :: from_raw ( thread as * mut Thread ) ;
13
13
drop ( thread) ;
14
14
}
15
15
16
16
unsafe fn clone ( thread : * const ( ) ) -> task:: RawWaker {
17
- let thread: Thread = mem :: transmute ( thread) ;
18
- let new_ptr = mem :: transmute ( thread. clone ( ) ) ;
17
+ let thread = Box :: from_raw ( thread as * mut Thread ) ;
18
+ let new_ptr = thread. clone ( ) ;
19
19
mem:: forget ( thread) ;
20
- task:: RawWaker :: new ( new_ptr, & VTABLE )
20
+ task:: RawWaker :: new ( Box :: into_raw ( new_ptr) as _ , & VTABLE )
21
21
}
22
22
23
- unsafe fn action ( thread : * const ( ) ) {
24
- let thread: Thread = mem:: transmute ( thread) ;
23
+ unsafe fn wake ( thread : * const ( ) ) {
24
+ let thread = Box :: from_raw ( thread as * mut ( ) as * mut Thread ) ;
25
+ thread. unpark ( ) ;
26
+ }
27
+
28
+ unsafe fn wake_by_ref ( thread : * const ( ) ) {
29
+ let thread = & * ( thread as * const Box < Thread > ) ;
25
30
thread. unpark ( ) ;
26
31
}
27
32
28
33
#[ inline( always) ]
29
34
pub fn waker ( thread : Thread ) -> task:: Waker {
35
+ //double pointer is so dumb...
36
+ let thread = Box :: new ( thread) ;
30
37
unsafe {
31
- task:: Waker :: from_raw ( task:: RawWaker :: new ( mem :: transmute ( thread) , & VTABLE ) )
38
+ task:: Waker :: from_raw ( task:: RawWaker :: new ( Box :: into_raw ( thread) as _ , & VTABLE ) )
32
39
}
33
40
}
34
41
}
0 commit comments