pub fn poll(&mut self) {
        let time = self.clocksource.counter();

        for i in 0..self.connections.len() {
            if let Some(timeout) = self.connections[Token(i)].get_timeout() {
                if time >= timeout {
                    self.timeout(Token(i));
                }
            }
        }
        let mut events = self.events.take().unwrap_or_else(
            || Events::with_capacity(MAX_EVENTS),
        );

        self.poll
            .poll(&mut events, Some(Duration::from_millis(TICK_MS)))
            .unwrap();

        let mut rtokens = Vec::new();

        for event in events.iter() {
            let token = event.token();
            if token.0 <= MAX_CONNECTIONS {
                trace!("connection ready {:?}", token);
                self.rtimes[token.0] = self.clocksource.counter();
                rtokens.push((token, event));
            } else {
                halt!("unknown token: {:?}", token);
            }
        }

        for (token, event) in rtokens {
            self.connection_ready(token, event);
        }

        for _ in 0..self.ready.len() {
            let token = self.ready.pop_front().unwrap();
            self.try_send(token);
        }

        self.events = Some(events);
    }
/// poll for events and handle them
poll for events and handle them
poll for events and handle them
pub fn poll(&mut self) {
        let time = self.clocksource.counter();
        for i in 0..self.connections.len() {
            if let Some(timeout) = self.connections[Token(i)].get_timeout() {
                if time >= timeout {
                    self.timeout(Token(i));
                }
            }
        }
        let mut events = self.events.take().unwrap_or_else(
            || Events::with_capacity(MAX_EVENTS),
        );
        self.poll
            .poll(&mut events, Some(Duration::from_millis(TICK_MS)))
            .unwrap();
        let mut rtokens = Vec::new();
        for event in events.iter() {
            let token = event.token();
            if token.0 <= MAX_CONNECTIONS {
                trace!("connection ready {:?}", token);
                self.rtimes[token.0] = self.clocksource.counter();
                rtokens.push((token, event));
            } else {
                halt!("unknown token: {:?}", token);
            }
        }
        for (token, event) in rtokens {
            self.connection_ready(token, event);
        }
        for _ in 0..self.ready.len() {
            let token = self.ready.pop_front().unwrap();
            self.try_send(token);
        }
        self.events = Some(events);
    }
pub fn poll ( & mut self ) { let time = self . clocksource . counter ( ) ; for i in 0 .. self . connections . len ( ) { if let Some ( timeout ) = self . connections [ Token ( i ) ] . get_timeout ( ) { if time >= timeout { self . timeout ( Token ( i ) ) ; } } } let mut events = self . events . take ( ) . unwrap_or_else ( | | Events :: with_capacity ( MAX_EVENTS ) , ) ; self . poll . poll ( & mut events , Some ( Duration :: from_millis ( TICK_MS ) ) ) . unwrap ( ) ; let mut rtokens = Vec :: new ( ) ; for event in events . iter ( ) { let token = event . token ( ) ; if token . 0 <= MAX_CONNECTIONS { trace ! ( " " token ) ; self . rtimes [ token . 0 ] = self . clocksource . counter ( ) ; rtokens . push ( ( token , event ) ) ; } else { halt ! ( " " token ) ; } } for ( token , event ) in rtokens { self . connection_ready ( token , event ) ; } for _ in 0 .. self . ready . len ( ) { let token = self . ready . pop_front ( ) . unwrap ( ) ; self . try_send ( token ) ; } self . events = Some ( events ) ; }
poll for events and handle them
poll for events and handle them
&mut self
&mut self