fn handle_update_thermal_load(
        &self,
        thermal_load: ThermalLoad,
    ) -> Result<MessageReturn, PowerManagerError> {
        fuchsia_trace::duration!(
            "power_manager",
            "ThermalLimiter::handle_update_thermal_load",
            "old_thermal_load" => self.thermal_load.get().0,
            "new_thermal_load" => thermal_load.0
        );
        if thermal_load > MAX_THERMAL_LOAD {
            return Err(PowerManagerError::InvalidArgument(format!(
                "Expected thermal_load in range [0-{}]; got {}",
                MAX_THERMAL_LOAD.0, thermal_load.0
            )));
        }

        // If the load hasn't changed, just bail here and return a success
        if thermal_load == self.thermal_load.get() {
            return Ok(MessageReturn::UpdateThermalLoad);
        }

        // Cache the thermal load value so if a new client connects we can give it the latest state
        self.thermal_load.set(thermal_load);
        self.inspect.thermal_load.set(thermal_load.0.into());

        // Check the client list for any closed proxies, and remove them from the list
        self.clients.borrow_mut().retain(|client| !client.proxy.is_closed());

        // Iterate through the clients to 1) update their local thermal state, and if that state
        // has changed, 2) create a future for the SetThermalState call out to that client.
        self.clients.borrow_mut().iter_mut().for_each(|client| {
            // If this client's state has changed...
            if let Some(state) = client.update_state(thermal_load) {
                self.send_thermal_state(client.proxy.clone(), state);
            }
        });

        Ok(MessageReturn::UpdateThermalLoad)
    }
/// Handle an UpdateThermalLoad message. If the thermal load has not changed from the previous
/// call, it is treated as a no-op.
Handle an UpdateThermalLoad message. If the thermal load has not changed from the previous
call, it is treated as a no-op.
Handle an UpdateThermalLoad message . If the thermal load has not changed from the previous call it is treated as a no - op .
fn handle_update_thermal_load(
        &self,
        thermal_load: ThermalLoad,
    ) -> Result<MessageReturn, PowerManagerError> {
        fuchsia_trace::duration!(
            "power_manager",
            "ThermalLimiter::handle_update_thermal_load",
            "old_thermal_load" => self.thermal_load.get().0,
            "new_thermal_load" => thermal_load.0
        );
        if thermal_load > MAX_THERMAL_LOAD {
            return Err(PowerManagerError::InvalidArgument(format!(
                "Expected thermal_load in range [0-{}]; got {}",
                MAX_THERMAL_LOAD.0, thermal_load.0
            )));
        }
        // If the load hasn't changed, just bail here and return a success
        if thermal_load == self.thermal_load.get() {
            return Ok(MessageReturn::UpdateThermalLoad);
        }
        // Cache the thermal load value so if a new client connects we can give it the latest state
        self.thermal_load.set(thermal_load);
        self.inspect.thermal_load.set(thermal_load.0.into());
        // Check the client list for any closed proxies, and remove them from the list
        self.clients.borrow_mut().retain(|client| !client.proxy.is_closed());
        // Iterate through the clients to 1) update their local thermal state, and if that state
        // has changed, 2) create a future for the SetThermalState call out to that client.
        self.clients.borrow_mut().iter_mut().for_each(|client| {
            // If this client's state has changed...
            if let Some(state) = client.update_state(thermal_load) {
                self.send_thermal_state(client.proxy.clone(), state);
            }
        });
        Ok(MessageReturn::UpdateThermalLoad)
    }
fn handle_update_thermal_load ( & self , thermal_load : ThermalLoad , ) -> Result < MessageReturn , PowerManagerError > { fuchsia_trace :: duration ! ( " " " " " " self thermal_load get ( ) 0 " " thermal_load 0 ) ; if thermal_load > MAX_THERMAL_LOAD { return Err ( PowerManagerError :: InvalidArgument ( format ! ( " " MAX_THERMAL_LOAD 0 thermal_load 0 ) ) ) ; } // If the load hasn't changed, just bail here and return a success if thermal_load == self . thermal_load . get ( ) { return Ok ( MessageReturn :: UpdateThermalLoad ) ; } // Cache the thermal load value so if a new client connects we can give it the latest state self . thermal_load . set ( thermal_load ) ; self . inspect . thermal_load . set ( thermal_load . 0 . into ( ) ) ; // Check the client list for any closed proxies, and remove them from the list self . clients . borrow_mut ( ) . retain ( | client | ! client . proxy . is_closed ( ) ) ; // Iterate through the clients to 1) update their local thermal state, and if that state // has changed, 2) create a future for the SetThermalState call out to that client. self . clients . borrow_mut ( ) . iter_mut ( ) . for_each ( | client | { // If this client's state has changed... if let Some ( state ) = client . update_state ( thermal_load ) { self . send_thermal_state ( client . proxy . clone ( ) , state ) ; } } ) ; Ok ( MessageReturn :: UpdateThermalLoad ) }
Handle an UpdateThermalLoad message.
Handle an UpdateThermalLoad message .
&self
thermal_load
ThermalLoad
&self
thermal_load
ThermalLoad