pub(crate) fn cancel(&self, key: TaskKey) -> bool {
        match self.ctrl.registry.get(key) {
            Some(task) => {
                let r = task.get_stop_reason();
                if r != StopReason::Cancelled {
                    task.set_stop_reason(StopReason::Cancelled);
                    if r == StopReason::Suspended {
                        self.ctrl.dec_suspended();
                        self.ctrl.scan_registry.set(true);
                    }
                    true
                } else { false }
            }
            _ => false,
        }
    }
//if rotate_once encounters cancelled task, then it will be removed from queue and registry
if rotate_once encounters cancelled task, then it will be removed from queue and registry
if rotate_once encounters cancelled task then it will be removed from queue and registry
pub(crate) fn cancel(&self, key: TaskKey) -> bool {
        match self.ctrl.registry.get(key) {
            Some(task) => {
                let r = task.get_stop_reason();
                if r != StopReason::Cancelled {
                    task.set_stop_reason(StopReason::Cancelled);
                    if r == StopReason::Suspended {
                        self.ctrl.dec_suspended();
                        self.ctrl.scan_registry.set(true);
                    }
                    true
                } else { false }
            }
            _ => false,
        }
    }
pub ( crate ) fn cancel ( & self , key : TaskKey ) -> bool { match self . ctrl . registry . get ( key ) { Some ( task ) => { let r = task . get_stop_reason ( ) ; if r != StopReason :: Cancelled { task . set_stop_reason ( StopReason :: Cancelled ) ; if r == StopReason :: Suspended { self . ctrl . dec_suspended ( ) ; self . ctrl . scan_registry . set ( true ) ; } true } else { false } } _ => false , } }
if rotate_once encounters cancelled task, then it will be removed from queue and registry
if rotate_once encounters cancelled task then it will be removed from queue and registry
&self
key
TaskKey
&self
key
TaskKey