@@ -236,6 +236,51 @@ impl<T: IsA<PollableOutputStream>> AsyncWrite for OutputStreamAsyncWrite<T> {
236
236
}
237
237
}
238
238
239
+ #[ cfg( any( feature = "v2_60" , feature = "dox" ) ) ]
240
+ #[ cfg_attr( feature = "dox" , doc( cfg( feature = "v2_60" ) ) ) ]
241
+ fn poll_write_vectored (
242
+ self : Pin < & mut Self > ,
243
+ cx : & mut Context < ' _ > ,
244
+ bufs : & [ io:: IoSlice < ' _ > ] ,
245
+ ) -> Poll < io:: Result < usize > > {
246
+ let stream = Pin :: get_ref ( self . as_ref ( ) ) ;
247
+ let vectors = bufs
248
+ . iter ( )
249
+ . map ( |v| OutputVector :: new ( & * * v) )
250
+ . collect :: < smallvec:: SmallVec < [ _ ; 2 ] > > ( ) ;
251
+ let gio_result = stream
252
+ . 0
253
+ . as_ref ( )
254
+ . writev_nonblocking ( & vectors, crate :: Cancellable :: NONE ) ;
255
+
256
+ match gio_result {
257
+ Ok ( ( PollableReturn :: Ok , size) ) => Poll :: Ready ( Ok ( size as usize ) ) ,
258
+ Ok ( ( PollableReturn :: WouldBlock , _) ) => {
259
+ let mut waker = Some ( cx. waker ( ) . clone ( ) ) ;
260
+ let source = stream. 0 . as_ref ( ) . create_source (
261
+ crate :: Cancellable :: NONE ,
262
+ None ,
263
+ glib:: PRIORITY_DEFAULT ,
264
+ move |_| {
265
+ if let Some ( waker) = waker. take ( ) {
266
+ waker. wake ( ) ;
267
+ }
268
+ glib:: Continue ( false )
269
+ } ,
270
+ ) ;
271
+ let main_context = glib:: MainContext :: ref_thread_default ( ) ;
272
+ source. attach ( Some ( & main_context) ) ;
273
+
274
+ Poll :: Pending
275
+ }
276
+ Ok ( ( _, _) ) => unreachable ! ( ) ,
277
+ Err ( err) => Poll :: Ready ( Err ( io:: Error :: new (
278
+ io:: ErrorKind :: from ( err. kind :: < crate :: IOErrorEnum > ( ) . unwrap ( ) ) ,
279
+ err,
280
+ ) ) ) ,
281
+ }
282
+ }
283
+
239
284
fn poll_flush ( self : Pin < & mut Self > , cx : & mut Context ) -> Poll < io:: Result < ( ) > > {
240
285
let stream = unsafe { Pin :: get_unchecked_mut ( self ) } ;
241
286
0 commit comments