fn run_hand_hot(&mut self, cold_page_required: bool) {
        let mut stop = Stop::new();
        while stop.check(self.hand_hot) {
            let mut page = self.hand_hot;
            let page = unsafe { page.as_mut() };
            self.hand_hot = page.next;

            match page.status {
                Status::Hot => if self.handle_hot(page) {
                    return;
                }
                Status::Cold | Status::Test => {
                    // Whenever the hand encounters a cold page, it will terminate the page’s test period.
                    page.status = Status::Cold;

                    // The hand will also remove the cold page from the clock if it is non-resident
                    // (the most probable case).
                    // TODO maybe not remove here and remove only when needed (non_resident_page_count > options.max_non_resident)
                    if !page.is_resident() {
                        let page = page.ptr();
                        self.remove_page(page, PageCountKind::Cold { resident: false });
                    } else {
                        stop.track(page.ptr())
                    }
                }
                Status::ProtectedTest | Status::End => stop.track(page.ptr()),
            }
        }
        // We did a cycle but could turn hot page into cold.
        // Cold hand relies on always being able to return a buffer when no new buffers can be created.
        // If the latter is the case we need to ensure there's at least one cold resident page available.
        if cold_page_required
            && self.resident_cold_page_count == 0
            && self.hot_page_count > 0
        {
            loop {
                let mut page = self.hand_hot;
                let page = unsafe { page.as_mut() };
                self.hand_hot = page.next;
                if page.status == Status::Hot && self.handle_hot(page) {
                    break;
                }
            }
        }
        debug_assert!(!cold_page_required || self.resident_cold_page_count > 0);
    }
/// If `cold_page_required` is `true` this method ensures that there's at least one resident
/// cold page available on return.
If `cold_page_required` is `true` this method ensures that there's at least one resident
cold page available on return.
If ` cold_page_required ` is ` true ` this method ensures that there ' s at least one resident cold page available on return .
fn run_hand_hot(&mut self, cold_page_required: bool) {
        let mut stop = Stop::new();
        while stop.check(self.hand_hot) {
            let mut page = self.hand_hot;
            let page = unsafe { page.as_mut() };
            self.hand_hot = page.next;
            match page.status {
                Status::Hot => if self.handle_hot(page) {
                    return;
                }
                Status::Cold | Status::Test => {
                    // Whenever the hand encounters a cold page, it will terminate the page’s test period.
                    page.status = Status::Cold;
                    // The hand will also remove the cold page from the clock if it is non-resident
                    // (the most probable case).
                    // TODO maybe not remove here and remove only when needed (non_resident_page_count > options.max_non_resident)
                    if !page.is_resident() {
                        let page = page.ptr();
                        self.remove_page(page, PageCountKind::Cold { resident: false });
                    } else {
                        stop.track(page.ptr())
                    }
                }
                Status::ProtectedTest | Status::End => stop.track(page.ptr()),
            }
        }
        // We did a cycle but could turn hot page into cold.
        // Cold hand relies on always being able to return a buffer when no new buffers can be created.
        // If the latter is the case we need to ensure there's at least one cold resident page available.
        if cold_page_required
            && self.resident_cold_page_count == 0
            && self.hot_page_count > 0
        {
            loop {
                let mut page = self.hand_hot;
                let page = unsafe { page.as_mut() };
                self.hand_hot = page.next;
                if page.status == Status::Hot && self.handle_hot(page) {
                    break;
                }
            }
        }
        debug_assert!(!cold_page_required || self.resident_cold_page_count > 0);
    }
fn run_hand_hot ( & mut self , cold_page_required : bool ) { let mut stop = Stop :: new ( ) ; while stop . check ( self . hand_hot ) { let mut page = self . hand_hot ; let page = unsafe { page . as_mut ( ) } ; self . hand_hot = page . next ; match page . status { Status :: Hot => if self . handle_hot ( page ) { return ; } Status :: Cold | Status :: Test => { // Whenever the hand encounters a cold page, it will terminate the page’s test period. page . status = Status :: Cold ; // The hand will also remove the cold page from the clock if it is non-resident // (the most probable case). // TODO maybe not remove here and remove only when needed (non_resident_page_count > options.max_non_resident) if ! page . is_resident ( ) { let page = page . ptr ( ) ; self . remove_page ( page , PageCountKind :: Cold { resident : false } ) ; } else { stop . track ( page . ptr ( ) ) } } Status :: ProtectedTest | Status :: End => stop . track ( page . ptr ( ) ) , } } // We did a cycle but could turn hot page into cold. // Cold hand relies on always being able to return a buffer when no new buffers can be created. // If the latter is the case we need to ensure there's at least one cold resident page available. if cold_page_required && self . resident_cold_page_count == 0 && self . hot_page_count > 0 { loop { let mut page = self . hand_hot ; let page = unsafe { page . as_mut ( ) } ; self . hand_hot = page . next ; if page . status == Status :: Hot && self . handle_hot ( page ) { break ; } } } debug_assert ! ( cold_page_required self resident_cold_page_count 0 ) ; }
If `cold_page_required` is `true` this method ensures that there's at least one resident
cold page available on return.
If ` cold_page_required ` is ` true ` this method ensures that there ' s at least one resident cold page available on return .
&mut self
cold_page_required
bool
&mut self
cold_page_required
bool