fn select_thermal_state(
        &self,
        available_power: Watts,
        performance_model: PerformanceModel,
    ) -> (usize, PerfAndPower) {
        // State 0 is guaranteed to be admissible. If it meets the power criterion, we return it.
        // Otherwise, we use it to initialize the fallback -- the lowest-index admissible state,
        // which will be used if no states meet the power criterion.
        debug_assert_eq!(self.thermal_states[0].min_performance, NormPerfs(0.0));
        let mut fallback = (0, self.thermal_states[0].estimate_perf_and_power(performance_model));
        if fallback.1.power < available_power {
            return fallback;
        }

        for (i, thermal_state) in self.thermal_states.iter().enumerate().skip(1) {
            if let FixedValue(performance) = performance_model {
                if thermal_state.min_performance > performance {
                    continue;
                }
            }

            let estimate = thermal_state.estimate_perf_and_power(performance_model);
            if estimate.power < available_power {
                return (i, estimate);
            }

            fallback = (i, estimate);
        }

        fallback
    }
// Determines the thermal state that should be used for the given available power and
// performance model, as well as its estimated performance and power.
Determines the thermal state that should be used for the given available power and
performance model, as well as its estimated performance and power.
Determines the thermal state that should be used for the given available power and performance model as well as its estimated performance and power .
fn select_thermal_state(
        &self,
        available_power: Watts,
        performance_model: PerformanceModel,
    ) -> (usize, PerfAndPower) {
        // State 0 is guaranteed to be admissible. If it meets the power criterion, we return it.
        // Otherwise, we use it to initialize the fallback -- the lowest-index admissible state,
        // which will be used if no states meet the power criterion.
        debug_assert_eq!(self.thermal_states[0].min_performance, NormPerfs(0.0));
        let mut fallback = (0, self.thermal_states[0].estimate_perf_and_power(performance_model));
        if fallback.1.power < available_power {
            return fallback;
        }
        for (i, thermal_state) in self.thermal_states.iter().enumerate().skip(1) {
            if let FixedValue(performance) = performance_model {
                if thermal_state.min_performance > performance {
                    continue;
                }
            }
            let estimate = thermal_state.estimate_perf_and_power(performance_model);
            if estimate.power < available_power {
                return (i, estimate);
            }
            fallback = (i, estimate);
        }
        fallback
    }
fn select_thermal_state ( & self , available_power : Watts , performance_model : PerformanceModel , ) -> ( usize , PerfAndPower ) { // State 0 is guaranteed to be admissible. If it meets the power criterion, we return it. // Otherwise, we use it to initialize the fallback -- the lowest-index admissible state, // which will be used if no states meet the power criterion. debug_assert_eq ! ( self thermal_states [ 0 ] min_performance NormPerfs ( 0.0 ) ) ; let mut fallback = ( 0 , self . thermal_states [ 0 ] . estimate_perf_and_power ( performance_model ) ) ; if fallback . 1 . power < available_power { return fallback ; } for ( i , thermal_state ) in self . thermal_states . iter ( ) . enumerate ( ) . skip ( 1 ) { if let FixedValue ( performance ) = performance_model { if thermal_state . min_performance > performance { continue ; } } let estimate = thermal_state . estimate_perf_and_power ( performance_model ) ; if estimate . power < available_power { return ( i , estimate ) ; } fallback = ( i , estimate ) ; } fallback }
Determines the thermal state that should be used for the given available power and
performance model, as well as its estimated performance and power.
Determines the thermal state that should be used for the given available power and performance model as well as its estimated performance and power .
&self
available_power
Watts
performance_model
PerformanceModel
&self
available_power
Watts
performance_model
PerformanceModel