async fn update_thermal_state(&self, index: usize) -> Result<(), PowerManagerError> {
        fuchsia_trace::duration!(
            "power_manager",
            "CpuManager::update_thermal_state",
            "index" => index as u32
        );

        // Return early if no update is required. We're assuming that P-states have not changed.
        if self.current_thermal_state.get() == Some(index) {
            return Ok(());
        }

        let pstate_indices = &self.thermal_states[index].cluster_pstates;
        let cluster_update_futures: Vec<_> = self
            .clusters
            .iter()
            .map(|cluster| {
                cluster.update_pstate(&self.syscall_handler, pstate_indices[cluster.cluster_index])
            })
            .collect();

        // Aggregate any errors that may have occurred when setting P-states.
        let errors: Vec<_> = futures::future::join_all(cluster_update_futures)
            .await
            .into_iter()
            .filter_map(|r| r.err())
            .collect();

        // Update the thermal state index.
        if errors.is_empty() {
            self.current_thermal_state.set(Some(index));
            self.inspect.thermal_state_index.set(&index.to_string());
            Ok(())
        } else {
            self.current_thermal_state.set(None);

            let msg = format!("P-state update(s) failed: {:?}", errors);
            self.inspect.thermal_state_index.set(&format!("Unknown; {}", msg));
            Err(format_err!(msg).into())
        }
    }
// Updates the current thermal state.
Updates the current thermal state.
Updates the current thermal state .
async fn update_thermal_state(&self, index: usize) -> Result<(), PowerManagerError> {
        fuchsia_trace::duration!(
            "power_manager",
            "CpuManager::update_thermal_state",
            "index" => index as u32
        );
        // Return early if no update is required. We're assuming that P-states have not changed.
        if self.current_thermal_state.get() == Some(index) {
            return Ok(());
        }
        let pstate_indices = &self.thermal_states[index].cluster_pstates;
        let cluster_update_futures: Vec<_> = self
            .clusters
            .iter()
            .map(|cluster| {
                cluster.update_pstate(&self.syscall_handler, pstate_indices[cluster.cluster_index])
            })
            .collect();
        // Aggregate any errors that may have occurred when setting P-states.
        let errors: Vec<_> = futures::future::join_all(cluster_update_futures)
            .await
            .into_iter()
            .filter_map(|r| r.err())
            .collect();
        // Update the thermal state index.
        if errors.is_empty() {
            self.current_thermal_state.set(Some(index));
            self.inspect.thermal_state_index.set(&index.to_string());
            Ok(())
        } else {
            self.current_thermal_state.set(None);
            let msg = format!("P-state update(s) failed: {:?}", errors);
            self.inspect.thermal_state_index.set(&format!("Unknown; {}", msg));
            Err(format_err!(msg).into())
        }
    }
async fn update_thermal_state ( & self , index : usize ) -> Result < ( ) , PowerManagerError > { fuchsia_trace :: duration ! ( " " " " " " index as u32 ) ; // Return early if no update is required. We're assuming that P-states have not changed. if self . current_thermal_state . get ( ) == Some ( index ) { return Ok ( ( ) ) ; } let pstate_indices = & self . thermal_states [ index ] . cluster_pstates ; let cluster_update_futures : Vec < _ > = self . clusters . iter ( ) . map ( | cluster | { cluster . update_pstate ( & self . syscall_handler , pstate_indices [ cluster . cluster_index ] ) } ) . collect ( ) ; // Aggregate any errors that may have occurred when setting P-states. let errors : Vec < _ > = futures :: future :: join_all ( cluster_update_futures ) . await . into_iter ( ) . filter_map ( | r | r . err ( ) ) . collect ( ) ; // Update the thermal state index. if errors . is_empty ( ) { self . current_thermal_state . set ( Some ( index ) ) ; self . inspect . thermal_state_index . set ( & index . to_string ( ) ) ; Ok ( ( ) ) } else { self . current_thermal_state . set ( None ) ; let msg = format ! ( " " errors ) ; self . inspect . thermal_state_index . set ( & format ! ( " " msg ) ) ; Err ( format_err ! ( msg ) . into ( ) ) } }
Updates the current thermal state.
Updates the current thermal state .
&self
index
usize
&self
index
usize