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