pub fn advance_replica_reads<T>(&mut self, states: T)
    where
        T: IntoIterator<Item = (Uuid, Option<LockInfo>, u64)>,
    {
        let (mut min_changed_offset, mut max_changed_offset) = (usize::MAX, 0);
        for (uuid, locked, index) in states {
            if let Some(raw_offset) = self.contexts.remove(&uuid) {
                let offset = match raw_offset.checked_sub(self.handled_cnt) {
                    Some(offset) => offset,
                    None => panic!(
                        "advance_replica_reads uuid: {}, offset: {}, handled: {}",
                        uuid, raw_offset, self.handled_cnt
                    ),
                };
                assert_eq!(
                    self.reads[offset].id, uuid,
                    "ReadIndexQueue::reads[{}].uuid: {}, but want: {}",
                    raw_offset, self.reads[offset].id, uuid
                );
                self.reads[offset].in_contexts = false;
                // clear addition_request to indicate lock checking has finished
                self.reads[offset].addition_request = None;
                self.reads[offset].locked = locked.map(Box::new);
                if let Some(occur_index) = self.reads[offset].read_index {
                    if occur_index < index {
                        continue;
                    }
                }
                self.reads[offset].read_index = Some(index);
                min_changed_offset = cmp::min(min_changed_offset, offset);
                max_changed_offset = cmp::max(max_changed_offset, offset);
                continue;
            }
            debug!(
                "cannot find corresponding read from pending reads";
                "uuid" => ?uuid, "read-index" => index,
            );
        }

        if min_changed_offset != usize::MAX {
            self.ready_cnt = cmp::max(self.ready_cnt, max_changed_offset + 1);
        }
        if max_changed_offset > 0 {
            self.fold(min_changed_offset, max_changed_offset);
        }
    }
/// update the read index of the requests that before the specified id.
update the read index of the requests that before the specified id.
update the read index of the requests that before the specified id .
pub fn advance_replica_reads<T>(&mut self, states: T)
    where
        T: IntoIterator<Item = (Uuid, Option<LockInfo>, u64)>,
    {
        let (mut min_changed_offset, mut max_changed_offset) = (usize::MAX, 0);
        for (uuid, locked, index) in states {
            if let Some(raw_offset) = self.contexts.remove(&uuid) {
                let offset = match raw_offset.checked_sub(self.handled_cnt) {
                    Some(offset) => offset,
                    None => panic!(
                        "advance_replica_reads uuid: {}, offset: {}, handled: {}",
                        uuid, raw_offset, self.handled_cnt
                    ),
                };
                assert_eq!(
                    self.reads[offset].id, uuid,
                    "ReadIndexQueue::reads[{}].uuid: {}, but want: {}",
                    raw_offset, self.reads[offset].id, uuid
                );
                self.reads[offset].in_contexts = false;
                // clear addition_request to indicate lock checking has finished
                self.reads[offset].addition_request = None;
                self.reads[offset].locked = locked.map(Box::new);
                if let Some(occur_index) = self.reads[offset].read_index {
                    if occur_index < index {
                        continue;
                    }
                }
                self.reads[offset].read_index = Some(index);
                min_changed_offset = cmp::min(min_changed_offset, offset);
                max_changed_offset = cmp::max(max_changed_offset, offset);
                continue;
            }
            debug!(
                "cannot find corresponding read from pending reads";
                "uuid" => ?uuid, "read-index" => index,
            );
        }
        if min_changed_offset != usize::MAX {
            self.ready_cnt = cmp::max(self.ready_cnt, max_changed_offset + 1);
        }
        if max_changed_offset > 0 {
            self.fold(min_changed_offset, max_changed_offset);
        }
    }
pub fn advance_replica_reads < T > ( & mut self , states : T ) where T : IntoIterator < Item = ( Uuid , Option < LockInfo > , u64 ) > , { let ( mut min_changed_offset , mut max_changed_offset ) = ( usize :: MAX , 0 ) ; for ( uuid , locked , index ) in states { if let Some ( raw_offset ) = self . contexts . remove ( & uuid ) { let offset = match raw_offset . checked_sub ( self . handled_cnt ) { Some ( offset ) => offset , None => panic ! ( " " uuid raw_offset self handled_cnt ) , } ; assert_eq ! ( self reads [ offset ] id uuid " " raw_offset self reads [ offset ] id uuid ) ; self . reads [ offset ] . in_contexts = false ; // clear addition_request to indicate lock checking has finished self . reads [ offset ] . addition_request = None ; self . reads [ offset ] . locked = locked . map ( Box :: new ) ; if let Some ( occur_index ) = self . reads [ offset ] . read_index { if occur_index < index { continue ; } } self . reads [ offset ] . read_index = Some ( index ) ; min_changed_offset = cmp :: min ( min_changed_offset , offset ) ; max_changed_offset = cmp :: max ( max_changed_offset , offset ) ; continue ; } debug ! ( " " " " uuid " " index ) ; } if min_changed_offset != usize :: MAX { self . ready_cnt = cmp :: max ( self . ready_cnt , max_changed_offset + 1 ) ; } if max_changed_offset > 0 { self . fold ( min_changed_offset , max_changed_offset ) ; } }
update the read index of the requests that before the specified id.
update the read index of the requests that before the specified id .
&mut self
states
T