fn call_with_metrics<F>(
        &self,
        sub_component: ConsensusSubcomponent,
        on_state_change: F,
    ) -> ChangeSet
    where
        F: FnOnce() -> ChangeSet,
    {
        self.last_invoked
            .borrow_mut()
            .insert(sub_component, self.time_source.get_relative_time());
        let name = sub_component.as_ref();
        let timer = self
            .metrics
            .on_state_change_duration
            .with_label_values(&[name])
            .start_timer();

        let change_set = on_state_change();

        timer.observe_duration();

        self.metrics
            .on_state_change_invocations
            .with_label_values(&[name])
            .inc();

        self.metrics
            .on_state_change_change_set_size
            .with_label_values(&[name])
            .observe(change_set.len() as f64);

        change_set
    }
/// Call the given sub-component's `on_state_change` function, mark the
/// time it takes to complete, increment its invocation counter, and mark
/// the size of the `ChangeSet` result.
Call the given sub-component's `on_state_change` function, mark the
time it takes to complete, increment its invocation counter, and mark
the size of the `ChangeSet` result.
Call the given sub - component ' s ` on_state_change ` function mark the time it takes to complete increment its invocation counter and mark the size of the ` ChangeSet ` result .
fn call_with_metrics<F>(
        &self,
        sub_component: ConsensusSubcomponent,
        on_state_change: F,
    ) -> ChangeSet
    where
        F: FnOnce() -> ChangeSet,
    {
        self.last_invoked
            .borrow_mut()
            .insert(sub_component, self.time_source.get_relative_time());
        let name = sub_component.as_ref();
        let timer = self
            .metrics
            .on_state_change_duration
            .with_label_values(&[name])
            .start_timer();
        let change_set = on_state_change();
        timer.observe_duration();
        self.metrics
            .on_state_change_invocations
            .with_label_values(&[name])
            .inc();
        self.metrics
            .on_state_change_change_set_size
            .with_label_values(&[name])
            .observe(change_set.len() as f64);
        change_set
    }
fn call_with_metrics < F > ( & self , sub_component : ConsensusSubcomponent , on_state_change : F , ) -> ChangeSet where F : FnOnce ( ) -> ChangeSet , { self . last_invoked . borrow_mut ( ) . insert ( sub_component , self . time_source . get_relative_time ( ) ) ; let name = sub_component . as_ref ( ) ; let timer = self . metrics . on_state_change_duration . with_label_values ( & [ name ] ) . start_timer ( ) ; let change_set = on_state_change ( ) ; timer . observe_duration ( ) ; self . metrics . on_state_change_invocations . with_label_values ( & [ name ] ) . inc ( ) ; self . metrics . on_state_change_change_set_size . with_label_values ( & [ name ] ) . observe ( change_set . len ( ) as f64 ) ; change_set }
Call the given sub-component's `on_state_change` function, mark the
time it takes to complete, increment its invocation counter, and mark
the size of the `ChangeSet` result.
Call the given sub - component ' s ` on_state_change ` function mark the time it takes to complete increment its invocation counter and mark the size of the ` ChangeSet ` result .
&self
sub_component
ConsensusSubcomponent
on_state_change
F
&self
sub_component
ConsensusSubcomponent
on_state_change
F