pub fn maybe_destroy<T, C>(
        &mut self,
        ctx: &PollContext<EK, ER, T, C>,
    ) -> Option<DestroyPeerJob> {
        if self.pending_remove {
            info!(
                "is being destroyed, skip";
                "region_id" => self.region_id,
                "peer_id" => self.peer.get_id(),
            );
            return None;
        }
        {
            let meta = ctx.store_meta.lock().unwrap();
            if meta.atomic_snap_regions.contains_key(&self.region_id) {
                info!(
                    "stale peer is applying atomic snapshot, will destroy next time";
                    "region_id" => self.region_id,
                    "peer_id" => self.peer.get_id(),
                );
                return None;
            }
        }

        if self.is_applying_snapshot() {
            if !self.mut_store().cancel_applying_snap() {
                info!(
                    "stale peer is applying snapshot, will destroy next time";
                    "region_id" => self.region_id,
                    "peer_id" => self.peer.get_id(),
                );
                return None;
            }
        }

        self.pending_remove = true;

        Some(DestroyPeerJob {
            initialized: self.get_store().is_initialized(),
            region_id: self.region_id,
            peer: self.peer.clone(),
        })
    }
/// Tries to destroy itself. Returns a job (if needed) to do more cleaning tasks.
Tries to destroy itself. Returns a job (if needed) to do more cleaning tasks.
Tries to destroy itself . Returns a job ( if needed ) to do more cleaning tasks .
pub fn maybe_destroy<T, C>(
        &mut self,
        ctx: &PollContext<EK, ER, T, C>,
    ) -> Option<DestroyPeerJob> {
        if self.pending_remove {
            info!(
                "is being destroyed, skip";
                "region_id" => self.region_id,
                "peer_id" => self.peer.get_id(),
            );
            return None;
        }
        {
            let meta = ctx.store_meta.lock().unwrap();
            if meta.atomic_snap_regions.contains_key(&self.region_id) {
                info!(
                    "stale peer is applying atomic snapshot, will destroy next time";
                    "region_id" => self.region_id,
                    "peer_id" => self.peer.get_id(),
                );
                return None;
            }
        }
        if self.is_applying_snapshot() {
            if !self.mut_store().cancel_applying_snap() {
                info!(
                    "stale peer is applying snapshot, will destroy next time";
                    "region_id" => self.region_id,
                    "peer_id" => self.peer.get_id(),
                );
                return None;
            }
        }
        self.pending_remove = true;
        Some(DestroyPeerJob {
            initialized: self.get_store().is_initialized(),
            region_id: self.region_id,
            peer: self.peer.clone(),
        })
    }
pub fn maybe_destroy < T , C > ( & mut self , ctx : & PollContext < EK , ER , T , C > , ) -> Option < DestroyPeerJob > { if self . pending_remove { info ! ( " " " " self region_id " " self peer get_id ( ) ) ; return None ; } { let meta = ctx . store_meta . lock ( ) . unwrap ( ) ; if meta . atomic_snap_regions . contains_key ( & self . region_id ) { info ! ( " " " " self region_id " " self peer get_id ( ) ) ; return None ; } } if self . is_applying_snapshot ( ) { if ! self . mut_store ( ) . cancel_applying_snap ( ) { info ! ( " " " " self region_id " " self peer get_id ( ) ) ; return None ; } } self . pending_remove = true ; Some ( DestroyPeerJob { initialized : self . get_store ( ) . is_initialized ( ) , region_id : self . region_id , peer : self . peer . clone ( ) , } ) }
Tries to destroy itself.
Tries to destroy itself .
&mut self
ctx
&PollContext<EK, ER, T, C>