fn calculate_lag(
        last_wait: Duration,
        target_interval: Duration,
        current_lag: Duration,
        catchup_enabled: bool,
    ) -> Duration {
        if catchup_enabled {
            if last_wait >= target_interval {
                let lost_time = last_wait - target_interval;
                current_lag + lost_time
            } else {
                let gained_time = target_interval - last_wait;
                if current_lag > gained_time {
                    current_lag - gained_time
                } else {
                    Duration::new(0, 0)
                }
            }
        } else {
            Duration::new(0, 0)
        }
    }
/// calculate the remaining lag after a loop iteration
calculate the remaining lag after a loop iteration
calculate the remaining lag after a loop iteration
fn calculate_lag(
        last_wait: Duration,
        target_interval: Duration,
        current_lag: Duration,
        catchup_enabled: bool,
    ) -> Duration {
        if catchup_enabled {
            if last_wait >= target_interval {
                let lost_time = last_wait - target_interval;
                current_lag + lost_time
            } else {
                let gained_time = target_interval - last_wait;
                if current_lag > gained_time {
                    current_lag - gained_time
                } else {
                    Duration::new(0, 0)
                }
            }
        } else {
            Duration::new(0, 0)
        }
    }
fn calculate_lag ( last_wait : Duration , target_interval : Duration , current_lag : Duration , catchup_enabled : bool , ) -> Duration { if catchup_enabled { if last_wait >= target_interval { let lost_time = last_wait - target_interval ; current_lag + lost_time } else { let gained_time = target_interval - last_wait ; if current_lag > gained_time { current_lag - gained_time } else { Duration :: new ( 0 , 0 ) } } } else { Duration :: new ( 0 , 0 ) } }
calculate the remaining lag after a loop iteration
calculate the remaining lag after a loop iteration
last_wait
Duration
target_interval
Duration
current_lag
Duration
catchup_enabled
bool