pub(crate) fn resume(&self, key: TaskKey) -> bool {
        match self.ctrl.registry.get(key) {
            Some(task) if task.get_stop_reason() == StopReason::Suspended => {
                task.set_stop_reason(StopReason::None);
                self.ctrl.dec_suspended();

                if task.is_runnable() || self.ctrl.current.get() == Some(key) {
                    // Check if absent is needed cause some task might spam suspend-resume
                    // which will otherwise cause multiple enqueues.
                    self.enqueue_runnable(key, true);
                } else {//task is still waiting for sth, defer it then
                    // Check if absent as above.
                    let mut deferred = self.ctrl.deferred.borrow_mut();
                    if !deferred.contains(&key) {
                        deferred.push(key);
                    }
                }
                true
            }
            _ => false,
        }
    }
//safe to call from inside task
safe to call from inside task
safe to call from inside task
pub(crate) fn resume(&self, key: TaskKey) -> bool {
        match self.ctrl.registry.get(key) {
            Some(task) if task.get_stop_reason() == StopReason::Suspended => {
                task.set_stop_reason(StopReason::None);
                self.ctrl.dec_suspended();
                if task.is_runnable() || self.ctrl.current.get() == Some(key) {
                    // Check if absent is needed cause some task might spam suspend-resume
                    // which will otherwise cause multiple enqueues.
                    self.enqueue_runnable(key, true);
                } else {//task is still waiting for sth, defer it then
                    // Check if absent as above.
                    let mut deferred = self.ctrl.deferred.borrow_mut();
                    if !deferred.contains(&key) {
                        deferred.push(key);
                    }
                }
                true
            }
            _ => false,
        }
    }
pub ( crate ) fn resume ( & self , key : TaskKey ) -> bool { match self . ctrl . registry . get ( key ) { Some ( task ) if task . get_stop_reason ( ) == StopReason :: Suspended => { task . set_stop_reason ( StopReason :: None ) ; self . ctrl . dec_suspended ( ) ; if task . is_runnable ( ) || self . ctrl . current . get ( ) == Some ( key ) { // Check if absent is needed cause some task might spam suspend-resume // which will otherwise cause multiple enqueues. self . enqueue_runnable ( key , true ) ; } else { //task is still waiting for sth, defer it then // Check if absent as above. let mut deferred = self . ctrl . deferred . borrow_mut ( ) ; if ! deferred . contains ( & key ) { deferred . push ( key ) ; } } true } _ => false , } }
safe to call from inside task
safe to call from inside task
&self
key
TaskKey
&self
key
TaskKey