/// Cancels the proc.
///
/// If the proc has already completed, calling this method will have no effect.
///
/// When a proc is cancelled, its future cannot be polled again and will be dropped instead.
Cancels the proc.
If the proc has already completed, calling this method will have no effect.

When a proc is cancelled, its future cannot be polled again and will be dropped instead.
Cancels the proc . If the proc has already completed calling this method will have no effect . When a proc is cancelled its future cannot be polled again and will be dropped instead .
pub fn cancel(&self) {
        let ptr = self.raw_proc.as_ptr();
        let pdata = ptr as *const ProcData;
        unsafe {
            let mut state = (*pdata).state.load(Ordering::Acquire);
            loop {
                // If the proc has been completed or closed, it can't be cancelled.
                if state & (COMPLETED | CLOSED) != 0 {
                    break;
                }
                // If the proc is not scheduled nor running, we'll need to schedule it.
                let new = if state & (SCHEDULED | RUNNING) == 0 {
                    (state | SCHEDULED | CLOSED) + REFERENCE
                } else {
                    state | CLOSED
                };
                // Mark the proc as closed.
                match (*pdata).state.compare_exchange_weak(
                    state,
                    new,
                    Ordering::AcqRel,
                    Ordering::Acquire,
                ) {
                    Ok(_) => {
                        // If the proc is not scheduled nor running, schedule it so that its future
                        // gets dropped by the executor.
                        if state & (SCHEDULED | RUNNING) == 0 {
                            ((*pdata).vtable.schedule)(ptr);
                        }
                        // Notify the awaiter that the proc has been closed.
                        if state & AWAITER != 0 {
                            (*pdata).notify();
                        }
                        break;
                    }
                    Err(s) => state = s,
                }
            }
        }
    }
pub fn cancel ( & self ) { let ptr = self . raw_proc . as_ptr ( ) ; let pdata = ptr as * const ProcData ; unsafe { let mut state = ( * pdata ) . state . load ( Ordering :: Acquire ) ; loop { // If the proc has been completed or closed, it can't be cancelled. if state & ( COMPLETED | CLOSED ) != 0 { break ; } // If the proc is not scheduled nor running, we'll need to schedule it. let new = if state & ( SCHEDULED | RUNNING ) == 0 { ( state | SCHEDULED | CLOSED ) + REFERENCE } else { state | CLOSED } ; // Mark the proc as closed. match ( * pdata ) . state . compare_exchange_weak ( state , new , Ordering :: AcqRel , Ordering :: Acquire , ) { Ok ( _ ) => { // If the proc is not scheduled nor running, schedule it so that its future // gets dropped by the executor. if state & ( SCHEDULED | RUNNING ) == 0 { ( ( * pdata ) . vtable . schedule ) ( ptr ) ; } // Notify the awaiter that the proc has been closed. if state & AWAITER != 0 { ( * pdata ) . notify ( ) ; } break ; } Err ( s ) => state = s , } } } }
Cancels the proc.
Cancels the proc .
&self