@@ -23,6 +23,9 @@ use std::{fmt, io};
23
23
24
24
use crate :: { event, sys, Events , Interest , Token } ;
25
25
26
+ #[ cfg( all( unix, feature = "os-ext" ) ) ]
27
+ use crate :: io_source:: IoSource ;
28
+
26
29
/// Polls for readiness events on all registered values.
27
30
///
28
31
/// `Poll` allows a program to monitor a large number of [`event::Source`]s,
@@ -265,6 +268,9 @@ use crate::{event, sys, Events, Interest, Token};
265
268
/// [`SourceFd`]: unix/struct.SourceFd.html
266
269
/// [`Poll::poll`]: struct.Poll.html#method.poll
267
270
pub struct Poll {
271
+ #[ cfg( all( unix, feature = "os-ext" ) ) ]
272
+ registry : IoSource < Registry > ,
273
+ #[ cfg( not( all( unix, feature = "os-ext" ) ) ) ]
268
274
registry : Registry ,
269
275
}
270
276
@@ -320,6 +326,13 @@ impl Poll {
320
326
/// ```
321
327
pub fn new( ) -> io:: Result <Poll > {
322
328
sys:: Selector :: new( ) . map( |selector| Poll {
329
+ #[ cfg( all( unix, feature = "os-ext" ) ) ]
330
+ registry: IoSource :: new( Registry {
331
+ selector,
332
+ #[ cfg( all( debug_assertions, not( target_os = "wasi" ) ) ) ]
333
+ has_waker: Arc :: new( AtomicBool :: new( false ) ) ,
334
+ } ) ,
335
+ #[ cfg( not( all( unix, feature = "os-ext" ) ) ) ]
323
336
registry: Registry {
324
337
selector,
325
338
#[ cfg( all( debug_assertions, not( target_os = "wasi" ) ) ) ]
@@ -464,6 +477,31 @@ impl fmt::Debug for Poll {
464
477
}
465
478
}
466
479
480
+ #[ cfg( all( unix, feature = "os-ext" ) ) ]
481
+ impl event:: Source for Poll {
482
+ fn register (
483
+ & mut self ,
484
+ registry : & Registry ,
485
+ token : Token ,
486
+ interests : Interest ,
487
+ ) -> io:: Result < ( ) > {
488
+ registry. register ( & mut self . registry , token, interests)
489
+ }
490
+
491
+ fn reregister (
492
+ & mut self ,
493
+ registry : & Registry ,
494
+ token : Token ,
495
+ interests : Interest ,
496
+ ) -> io:: Result < ( ) > {
497
+ registry. reregister ( & mut self . registry , token, interests)
498
+ }
499
+
500
+ fn deregister ( & mut self , registry : & Registry ) -> io:: Result < ( ) > {
501
+ registry. deregister ( & mut self . registry )
502
+ }
503
+ }
504
+
467
505
impl Registry {
468
506
/// Register an [`event::Source`] with the `Poll` instance.
469
507
///
0 commit comments