pub(crate) fn cancel(&self) {
        let mut state = self.state.load(Ordering::Acquire);

        loop {
            // If the task has been completed or closed, it can't be cancelled.
            if state & (COMPLETED | CLOSED) != 0 {
                break;
            }

            // Mark the task as closed.
            match self.state.compare_exchange_weak(
                state,
                state | CLOSED,
                Ordering::AcqRel,
                Ordering::Acquire,
            ) {
                Ok(_) => {
                    // Notify the awaiter that the task has been closed.
                    if state & AWAITER != 0 {
                        self.notify();
                    }

                    break;
                }
                Err(s) => state = s,
            }
        }
    }
/// Cancels the task.
///
/// This method will mark the task as closed and notify the awaiter, but it won't reschedule
/// the task if it's not completed.
Cancels the task.
This method will mark the task as closed and notify the awaiter, but it won't reschedule
the task if it's not completed.
Cancels the task . This method will mark the task as closed and notify the awaiter but it won ' t reschedule the task if it ' s not completed .
pub(crate) fn cancel(&self) {
        let mut state = self.state.load(Ordering::Acquire);
        loop {
            // If the task has been completed or closed, it can't be cancelled.
            if state & (COMPLETED | CLOSED) != 0 {
                break;
            }
            // Mark the task as closed.
            match self.state.compare_exchange_weak(
                state,
                state | CLOSED,
                Ordering::AcqRel,
                Ordering::Acquire,
            ) {
                Ok(_) => {
                    // Notify the awaiter that the task has been closed.
                    if state & AWAITER != 0 {
                        self.notify();
                    }
                    break;
                }
                Err(s) => state = s,
            }
        }
    }
pub ( crate ) fn cancel ( & self ) { let mut state = self . state . load ( Ordering :: Acquire ) ; loop { // If the task has been completed or closed, it can't be cancelled. if state & ( COMPLETED | CLOSED ) != 0 { break ; } // Mark the task as closed. match self . state . compare_exchange_weak ( state , state | CLOSED , Ordering :: AcqRel , Ordering :: Acquire , ) { Ok ( _ ) => { // Notify the awaiter that the task has been closed. if state & AWAITER != 0 { self . notify ( ) ; } break ; } Err ( s ) => state = s , } } }
Cancels the task.
Cancels the task .
&self
&self