fn poll_background_errors(&mut self, cx: &mut Context) -> Result<(), BoxError> {
        if let Some(result) = self.receive_tasks_if_needed() {
            return result;
        }

        match Pin::new(&mut self.guards).poll_next(cx) {
            // All background tasks are still running.
            Poll::Pending => Ok(()),

            Poll::Ready(Some(res)) => {
                info!(
                    background_tasks = %self.guards.len(),
                    "a peer set background task exited, shutting down other peer set tasks"
                );

                self.shut_down_tasks_and_channels();

                // Flatten the join result and inner result,
                // then turn Ok() task exits into errors.
                res.map_err(Into::into)
                    // TODO: replace with Result::flatten when it stabilises (#70142)
                    .and_then(convert::identity)
                    .and(Err("a peer set background task exited".into()))
            }

            Poll::Ready(None) => {
                self.shut_down_tasks_and_channels();
                Err("all peer set background tasks have exited".into())
            }
        }
    }
/// Check background task handles to make sure they're still running.
///
/// If any background task exits, shuts down all other background tasks,
/// and returns an error.
Check background task handles to make sure they're still running.
If any background task exits, shuts down all other background tasks,
and returns an error.
Check background task handles to make sure they ' re still running . If any background task exits shuts down all other background tasks and returns an error .
fn poll_background_errors(&mut self, cx: &mut Context) -> Result<(), BoxError> {
        if let Some(result) = self.receive_tasks_if_needed() {
            return result;
        }
        match Pin::new(&mut self.guards).poll_next(cx) {
            // All background tasks are still running.
            Poll::Pending => Ok(()),
            Poll::Ready(Some(res)) => {
                info!(
                    background_tasks = %self.guards.len(),
                    "a peer set background task exited, shutting down other peer set tasks"
                );
                self.shut_down_tasks_and_channels();
                // Flatten the join result and inner result,
                // then turn Ok() task exits into errors.
                res.map_err(Into::into)
                    // TODO: replace with Result::flatten when it stabilises (#70142)
                    .and_then(convert::identity)
                    .and(Err("a peer set background task exited".into()))
            }
            Poll::Ready(None) => {
                self.shut_down_tasks_and_channels();
                Err("all peer set background tasks have exited".into())
            }
        }
    }
fn poll_background_errors ( & mut self , cx : & mut Context ) -> Result < ( ) , BoxError > { if let Some ( result ) = self . receive_tasks_if_needed ( ) { return result ; } match Pin :: new ( & mut self . guards ) . poll_next ( cx ) { // All background tasks are still running. Poll :: Pending => Ok ( ( ) ) , Poll :: Ready ( Some ( res ) ) => { info ! ( background_tasks self guards len ( ) " " ) ; self . shut_down_tasks_and_channels ( ) ; // Flatten the join result and inner result, // then turn Ok() task exits into errors. res . map_err ( Into :: into ) // TODO: replace with Result::flatten when it stabilises (#70142) . and_then ( convert :: identity ) . and ( Err ( " " . into ( ) ) ) } Poll :: Ready ( None ) => { self . shut_down_tasks_and_channels ( ) ; Err ( " " . into ( ) ) } } }
Check background task handles to make sure they're still running.
Check background task handles to make sure they ' re still running .
&mut self
cx
&mut Context