pub(crate) fn poll(&mut self, timeout: Duration) -> io::Result<bool> {
        // Since our I/O events are oneshot, make sure we re-register sockets
        // with the poller that previously were triggered last time we polled.
        //
        // We don't do this immediately after polling because the caller may
        // choose to de-register a socket before the next call. That's why we
        // wait until the last minute.
        for event in self.events.drain(..) {
            let socket = event.key as Socket;
            if let Some(registration) = self.sockets.get_mut(&socket) {
                // If the socket was already re-registered this tick, then we
                // don't need to do this.
                if registration.tick != self.tick {
                    poller_modify(
                        &self.poller,
                        socket,
                        registration.readable,
                        registration.writable,
                    )?;
                    registration.tick = self.tick;
                }
            }
        }

        // Iterate over sockets that have been registered, but failed to be
        // added to the underlying poller temporarily, and retry adding them.
        self.bad_sockets.retain({
            let sockets = &mut self.sockets;
            let poller = &self.poller;
            let tick = self.tick;

            move |&socket| {
                if let Some(registration) = sockets.get_mut(&socket) {
                    if registration.tick != tick {
                        registration.tick = tick;
                        poller_add(poller, socket, registration.readable, registration.writable)
                            .is_err()
                    } else {
                        true
                    }
                } else {
                    false
                }
            }
        });

        self.tick = self.tick.wrapping_add(1);

        // Block until either an I/O event occurs on a socket, the timeout is
        // reached, or the agent handle interrupts us.
        match self.poller.wait(&mut self.events, Some(timeout)) {
            Ok(0) => Ok(false),
            Ok(_) => Ok(true),
            Err(e) if e.kind() == io::ErrorKind::Interrupted => Ok(false),
            Err(e) => Err(e),
        }
    }
/// Block until socket activity is detected or a timeout passes.
///
/// Returns `true` if one or more socket events occurred.
Block until socket activity is detected or a timeout passes.
Returns `true` if one or more socket events occurred.
Block until socket activity is detected or a timeout passes . Returns ` true ` if one or more socket events occurred .
pub(crate) fn poll(&mut self, timeout: Duration) -> io::Result<bool> {
        // Since our I/O events are oneshot, make sure we re-register sockets
        // with the poller that previously were triggered last time we polled.
        //
        // We don't do this immediately after polling because the caller may
        // choose to de-register a socket before the next call. That's why we
        // wait until the last minute.
        for event in self.events.drain(..) {
            let socket = event.key as Socket;
            if let Some(registration) = self.sockets.get_mut(&socket) {
                // If the socket was already re-registered this tick, then we
                // don't need to do this.
                if registration.tick != self.tick {
                    poller_modify(
                        &self.poller,
                        socket,
                        registration.readable,
                        registration.writable,
                    )?;
                    registration.tick = self.tick;
                }
            }
        }
        // Iterate over sockets that have been registered, but failed to be
        // added to the underlying poller temporarily, and retry adding them.
        self.bad_sockets.retain({
            let sockets = &mut self.sockets;
            let poller = &self.poller;
            let tick = self.tick;
            move |&socket| {
                if let Some(registration) = sockets.get_mut(&socket) {
                    if registration.tick != tick {
                        registration.tick = tick;
                        poller_add(poller, socket, registration.readable, registration.writable)
                            .is_err()
                    } else {
                        true
                    }
                } else {
                    false
                }
            }
        });
        self.tick = self.tick.wrapping_add(1);
        // Block until either an I/O event occurs on a socket, the timeout is
        // reached, or the agent handle interrupts us.
        match self.poller.wait(&mut self.events, Some(timeout)) {
            Ok(0) => Ok(false),
            Ok(_) => Ok(true),
            Err(e) if e.kind() == io::ErrorKind::Interrupted => Ok(false),
            Err(e) => Err(e),
        }
    }
pub ( crate ) fn poll ( & mut self , timeout : Duration ) -> io :: Result < bool > { // Since our I/O events are oneshot, make sure we re-register sockets // with the poller that previously were triggered last time we polled. // // We don't do this immediately after polling because the caller may // choose to de-register a socket before the next call. That's why we // wait until the last minute. for event in self . events . drain ( .. ) { let socket = event . key as Socket ; if let Some ( registration ) = self . sockets . get_mut ( & socket ) { // If the socket was already re-registered this tick, then we // don't need to do this. if registration . tick != self . tick { poller_modify ( & self . poller , socket , registration . readable , registration . writable , ) ? ; registration . tick = self . tick ; } } } // Iterate over sockets that have been registered, but failed to be // added to the underlying poller temporarily, and retry adding them. self . bad_sockets . retain ( { let sockets = & mut self . sockets ; let poller = & self . poller ; let tick = self . tick ; move | & socket | { if let Some ( registration ) = sockets . get_mut ( & socket ) { if registration . tick != tick { registration . tick = tick ; poller_add ( poller , socket , registration . readable , registration . writable ) . is_err ( ) } else { true } } else { false } } } ) ; self . tick = self . tick . wrapping_add ( 1 ) ; // Block until either an I/O event occurs on a socket, the timeout is // reached, or the agent handle interrupts us. match self . poller . wait ( & mut self . events , Some ( timeout ) ) { Ok ( 0 ) => Ok ( false ) , Ok ( _ ) => Ok ( true ) , Err ( e ) if e . kind ( ) == io :: ErrorKind :: Interrupted => Ok ( false ) , Err ( e ) => Err ( e ) , } }
Block until socket activity is detected or a timeout passes.
Block until socket activity is detected or a timeout passes .
&mut self
timeout
Duration