pub(crate) fn suspend(&self, key: TaskKey) -> bool {
        match self.ctrl.registry.get(key) {
            Some(task) if task.get_stop_reason() == StopReason::None => {
                task.set_stop_reason(StopReason::Suspended);
                self.ctrl.inc_suspended();
                //optimistic check, if is runnable then for sure will be removed from deferred
                //in next iteration
                if !task.is_runnable() {
                    let mut deferred = self.ctrl.deferred.borrow_mut();
                    if let Some(pos) = deferred.iter().position(|x| *x == key) {
                        deferred.remove(pos);
                    }
                }

                true
            }
            _ => false,
        }
    }
//if rotate_once encounters suspended task, then it will be removed from queue
if rotate_once encounters suspended task, then it will be removed from queue
if rotate_once encounters suspended task then it will be removed from queue
pub(crate) fn suspend(&self, key: TaskKey) -> bool {
        match self.ctrl.registry.get(key) {
            Some(task) if task.get_stop_reason() == StopReason::None => {
                task.set_stop_reason(StopReason::Suspended);
                self.ctrl.inc_suspended();
                //optimistic check, if is runnable then for sure will be removed from deferred
                //in next iteration
                if !task.is_runnable() {
                    let mut deferred = self.ctrl.deferred.borrow_mut();
                    if let Some(pos) = deferred.iter().position(|x| *x == key) {
                        deferred.remove(pos);
                    }
                }
                true
            }
            _ => false,
        }
    }
pub ( crate ) fn suspend ( & self , key : TaskKey ) -> bool { match self . ctrl . registry . get ( key ) { Some ( task ) if task . get_stop_reason ( ) == StopReason :: None => { task . set_stop_reason ( StopReason :: Suspended ) ; self . ctrl . inc_suspended ( ) ; //optimistic check, if is runnable then for sure will be removed from deferred //in next iteration if ! task . is_runnable ( ) { let mut deferred = self . ctrl . deferred . borrow_mut ( ) ; if let Some ( pos ) = deferred . iter ( ) . position ( | x | * x == key ) { deferred . remove ( pos ) ; } } true } _ => false , } }
if rotate_once encounters suspended task, then it will be removed from queue
if rotate_once encounters suspended task then it will be removed from queue
&self
key
TaskKey
&self
key
TaskKey