insanity
parent: tbd commit: 6ea28ab
1 | use BoxFuture; |
2 | use FutureExt; |
3 | use |
4 | , FfiValueUntyped, FfiFuture, FfiValue, FfiValueMut, FfiValueRef, | State
5 | RuntimeFuturePoll, |
6 | ; |
7 | use |
8 | , | UnsafeCell
9 | , | Future
10 | , | PhantomData
11 | , | transmute
12 | , | Deref
13 | , |
14 | ; |
15 | |
16 | |
17 | |
18 | callback: FfiValueUntyped, |
19 | waker_func: unsafe extern "C" fn , |
20 | |
21 | |
22 | |
23 | waker: Waker, |
24 | |
25 | |
26 | unsafe extern "C" |
27 | |
28 | |
29 | inner: , |
30 | runtime_future: , |
31 | |
32 | |
33 | unsafe |
34 | unsafe |
35 | |
36 | |
37 | |
38 | |
39 | |
40 | todo! |
41 | |
42 | |
43 | |
44 | |
45 | |
46 | &self, |
47 | future: F, |
48 | ; |
49 | |
50 | |
51 | |
52 | |
53 | &self, |
54 | future: F, |
55 | |
56 | // let type_eraser = async move { |
57 | // let result = future.await; |
58 | |
59 | // FFIBox::from_box(Box::new(result)).untyped() |
60 | // }; |
61 | |
62 | // let runtime_future = unsafe { FfiFuture::from_raw(poll_local, type_eraser.boxed()) }; |
63 | |
64 | // RuntimeFuture(runtime_future) |
65 | |
66 | todo! |
67 | |
68 | |
69 | |
70 | unsafe extern "C" |
71 | _future: , |
72 | mut future_state: , |
73 | |
74 | let mut future_state: = transmute; |
75 | |
76 | let runtime_future = future_state.as_ref; |
77 | |
78 | let raw_waker = new |
79 | Box into_raw as *const , |
80 | &RUNTIME_FUTURE_WAKER_VTABLE, |
81 | ; |
82 | |
83 | let waker = unsafe ; |
84 | |
85 | // SAFETY: Pretty sure this has to be static lol |
86 | let poll_result = future_state.poll_unpin; |
87 | |
88 | match poll_result |
89 | => Ready, | Ready
90 | => Pending, | Pending
91 | |
92 | |
93 | |
94 | pub static RUNTIME_FUTURE_WAKER_VTABLE: RawWakerVTable = new |
95 | , | waker_clone
96 | , | waker_wake
97 | , | waker_wake_by_ref
98 | , | waker_drop
99 | ; |
100 | |
101 | |
102 | use RawWaker; |
103 | |
104 | pub unsafe |
105 | todo! |
106 | |
107 | |
108 | pub unsafe |
109 | todo! |
110 | |
111 | |
112 | pub unsafe |
113 | todo! |
114 | |
115 | |
116 | pub unsafe |
117 | // no-op |
118 | |
119 | |
120 | |
121 | |
122 | ; |
123 | |
124 | /// Allows for a remote future to be polled on the target. |
125 | /// |
126 | /// The target can be the host or a plugin, but the future should only be polled by one |
127 | /// source. |
128 | |
129 | type Output = Output; |
130 | |
131 | |
132 | mut self: , |
133 | cx: &mut , |
134 | |
135 | let waker_state = WakerState |
136 | waker: cx.waker .clone, |
137 | ; |
138 | |
139 | unsafe ; |
140 | |
141 | match unsafe |
142 | => | Ready
143 | let result: = unsafe ; |
144 | |
145 | Ready |
146 | |
147 | => Pending, | Pending
148 | |
149 | |
150 | |
151 | |
152 | /// The function used to wake a local future over FFI |
153 | unsafe extern "C" |
154 | if let Some = &future.waker_state |
155 | let waker: = unsafe ; |
156 | |
157 | waker.waker.wake_by_ref; |
158 | |
159 | |
160 |