pub fn run(&mut self) -> () {
        let mut events = Events::with_capacity(MAX_POLL_EVENTS);
        debug!(self.log, "Entering main EventLoop");
        let mut retry_queue = VecDeque::<(Token, bool, bool, usize)>::new();
        let mut timeout;
        loop {
            // Retries happen for connection interrupts and buffer-swapping
            // Performed in the main loop to avoid recursion
            retry_queue.append(&mut self.retry_queue);
            timeout = if self.out_of_buffers {
                // Avoid looping retries when there are no Buffers
                Some(Duration::from_millis(
                    self.network_config.get_connection_retry_interval(),
                ))
            } else if retry_queue.is_empty() {
                None
            }
            // No need to timeout if there are no retries
            else {
                Some(Duration::from_secs(0))
            }; // Timeout immediately if retries are waiting

            self.poll
                .poll(&mut events, timeout)
                .expect("Error when calling Poll");

            for (token, readable, writeable, retries) in events
                .iter()
                .map(|e| (e.token(), e.is_readable(), e.is_writable(), 0_usize))
                .chain(retry_queue.drain(0..retry_queue.len()))
            {
                self.handle_event(token, readable, writeable, retries);

                if self.stopped {
                    let promise = self.shutdown_promise.take().expect("shutdown promise");
                    if let Err(e) = promise.fulfil(()) {
                        error!(self.log, "Error, shutting down sender: {:?}", e);
                    };
                    debug!(self.log, "Stopped");
                    return;
                };
            }
        }
    }
/// Event loop, spawn a thread calling this method start the thread.
Event loop, spawn a thread calling this method start the thread.
Event loop spawn a thread calling this method start the thread .
pub fn run(&mut self) -> () {
        let mut events = Events::with_capacity(MAX_POLL_EVENTS);
        debug!(self.log, "Entering main EventLoop");
        let mut retry_queue = VecDeque::<(Token, bool, bool, usize)>::new();
        let mut timeout;
        loop {
            // Retries happen for connection interrupts and buffer-swapping
            // Performed in the main loop to avoid recursion
            retry_queue.append(&mut self.retry_queue);
            timeout = if self.out_of_buffers {
                // Avoid looping retries when there are no Buffers
                Some(Duration::from_millis(
                    self.network_config.get_connection_retry_interval(),
                ))
            } else if retry_queue.is_empty() {
                None
            }
            // No need to timeout if there are no retries
            else {
                Some(Duration::from_secs(0))
            }; // Timeout immediately if retries are waiting
            self.poll
                .poll(&mut events, timeout)
                .expect("Error when calling Poll");
            for (token, readable, writeable, retries) in events
                .iter()
                .map(|e| (e.token(), e.is_readable(), e.is_writable(), 0_usize))
                .chain(retry_queue.drain(0..retry_queue.len()))
            {
                self.handle_event(token, readable, writeable, retries);
                if self.stopped {
                    let promise = self.shutdown_promise.take().expect("shutdown promise");
                    if let Err(e) = promise.fulfil(()) {
                        error!(self.log, "Error, shutting down sender: {:?}", e);
                    };
                    debug!(self.log, "Stopped");
                    return;
                };
            }
        }
    }
pub fn run ( & mut self ) -> ( ) { let mut events = Events :: with_capacity ( MAX_POLL_EVENTS ) ; debug ! ( self log " " ) ; let mut retry_queue = VecDeque :: < ( Token , bool , bool , usize ) > :: new ( ) ; let mut timeout ; loop { // Retries happen for connection interrupts and buffer-swapping // Performed in the main loop to avoid recursion retry_queue . append ( & mut self . retry_queue ) ; timeout = if self . out_of_buffers { // Avoid looping retries when there are no Buffers Some ( Duration :: from_millis ( self . network_config . get_connection_retry_interval ( ) , ) ) } else if retry_queue . is_empty ( ) { None } // No need to timeout if there are no retries else { Some ( Duration :: from_secs ( 0 ) ) } ; // Timeout immediately if retries are waiting self . poll . poll ( & mut events , timeout ) . expect ( " " ) ; for ( token , readable , writeable , retries ) in events . iter ( ) . map ( | e | ( e . token ( ) , e . is_readable ( ) , e . is_writable ( ) , 0_usize ) ) . chain ( retry_queue . drain ( 0 .. retry_queue . len ( ) ) ) { self . handle_event ( token , readable , writeable , retries ) ; if self . stopped { let promise = self . shutdown_promise . take ( ) . expect ( " " ) ; if let Err ( e ) = promise . fulfil ( ( ) ) { error ! ( self log " " e ) ; } ; debug ! ( self log " " ) ; return ; } ; } } }
Event loop, spawn a thread calling this method start the thread.
Event loop spawn a thread calling this method start the thread .
&mut self
&mut self