1
- use crate :: connections:: SignalArgArrayToTuple ;
2
1
use std:: future:: Future ;
3
2
use std:: os:: raw:: c_void;
4
3
use std:: pin:: Pin ;
4
+ use std:: task:: { Context , Poll , RawWaker , RawWakerVTable , Waker } ;
5
+
6
+ use crate :: connections:: SignalArgArrayToTuple ;
7
+
5
8
6
- static QT_WAKER_VTABLE : std :: task :: RawWakerVTable = unsafe {
7
- std :: task :: RawWakerVTable :: new (
9
+ static QT_WAKER_VTABLE : RawWakerVTable = unsafe {
10
+ RawWakerVTable :: new (
8
11
|s : * const ( ) | {
9
- std :: task :: RawWaker :: new (
12
+ RawWaker :: new (
10
13
cpp ! ( [ s as "Waker *" ] -> * const ( ) as "Waker *" {
11
14
s->refs++;
12
15
return s;
@@ -117,9 +120,9 @@ pub fn execute_async(f: impl Future<Output = ()> + 'static) {
117
120
// SAFETY: caller must ensure that given future hasn't returned Poll::Ready earlier.
118
121
unsafe fn poll_with_qt_waker ( waker : * const ( ) , future : Pin < & mut dyn Future < Output = ( ) > > ) -> bool {
119
122
cpp ! ( [ waker as "Waker *" ] { waker->refs++; } ) ;
120
- let waker = std :: task :: RawWaker :: new ( waker, & QT_WAKER_VTABLE ) ;
121
- let waker = std :: task :: Waker :: from_raw ( waker) ;
122
- let mut context = std :: task :: Context :: from_waker ( & waker) ;
123
+ let waker = RawWaker :: new ( waker, & QT_WAKER_VTABLE ) ;
124
+ let waker = Waker :: from_raw ( waker) ;
125
+ let mut context = Context :: from_waker ( & waker) ;
123
126
future. poll ( & mut context) . is_ready ( )
124
127
}
125
128
@@ -139,7 +142,7 @@ pub unsafe fn wait_on_signal<Args: SignalArgArrayToTuple>(
139
142
) -> impl Future < Output = <Args as SignalArgArrayToTuple >:: Tuple > {
140
143
enum ConnectionFutureState < Args : SignalArgArrayToTuple > {
141
144
Init { sender : * const c_void , signal : crate :: connections:: Signal < Args > } ,
142
- Started { handle : crate :: connections:: ConnectionHandle , waker : std :: task :: Waker } ,
145
+ Started { handle : crate :: connections:: ConnectionHandle , waker : Waker } ,
143
146
Finished { result : <Args as SignalArgArrayToTuple >:: Tuple } ,
144
147
Invalid ,
145
148
}
@@ -160,12 +163,12 @@ pub unsafe fn wait_on_signal<Args: SignalArgArrayToTuple>(
160
163
type Output = <Args as SignalArgArrayToTuple >:: Tuple ;
161
164
fn poll (
162
165
mut self : Pin < & mut Self > ,
163
- ctx : & mut std :: task :: Context ,
164
- ) -> std :: task :: Poll < Self :: Output > {
166
+ ctx : & mut Context ,
167
+ ) -> Poll < Self :: Output > {
165
168
let state = & mut self . 0 ;
166
169
* state = match std:: mem:: replace ( state, ConnectionFutureState :: Invalid ) {
167
170
ConnectionFutureState :: Finished { result } => {
168
- return std :: task :: Poll :: Ready ( result) ;
171
+ return Poll :: Ready ( result) ;
169
172
}
170
173
ConnectionFutureState :: Init { sender, signal } => {
171
174
let s_ptr = state as * mut ConnectionFutureState < _ > ;
@@ -176,7 +179,7 @@ pub unsafe fn wait_on_signal<Args: SignalArgArrayToTuple>(
176
179
s @ ConnectionFutureState :: Started { .. } => s,
177
180
ConnectionFutureState :: Invalid => unreachable ! ( ) ,
178
181
} ;
179
- std :: task :: Poll :: Pending
182
+ Poll :: Pending
180
183
}
181
184
}
182
185
0 commit comments