unsafe fn wake_by_ref(ptr: *const ()) {
        let raw = Self::from_ptr(ptr);

        let mut state = (*raw.pdata).state.load(Ordering::Acquire);

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

            // If the proc is already scheduled, we just need to synchronize with the thread that
            // will run the proc by "publishing" our current view of the memory.
            if state & SCHEDULED != 0 {
                // Update the state without actually modifying it.
                match (*raw.pdata).state.compare_exchange_weak(
                    state,
                    state,
                    Ordering::AcqRel,
                    Ordering::Acquire,
                ) {
                    Ok(_) => break,
                    Err(s) => state = s,
                }
            } else {
                // If the proc is not scheduled nor running, we'll need to schedule after waking.
                let new = if state & (SCHEDULED | RUNNING) == 0 {
                    (state | SCHEDULED) + REFERENCE
                } else {
                    state | SCHEDULED
                };

                // Mark the proc as scheduled.
                match (*raw.pdata).state.compare_exchange_weak(
                    state,
                    new,
                    Ordering::AcqRel,
                    Ordering::Acquire,
                ) {
                    Ok(_) => {
                        // If the proc is not scheduled nor running, now is the time to schedule.
                        if state & (SCHEDULED | RUNNING) == 0 {
                            // If the reference count overflowed, abort.
                            if state > isize::max_value() as usize {
                                std::process::abort();
                            }

                            // Schedule the proc.
                            let proc = LightProc {
                                raw_proc: NonNull::new_unchecked(ptr as *mut ()),
                            };
                            (*raw.schedule)(proc);
                        }

                        break;
                    }
                    Err(s) => state = s,
                }
            }
        }
    }
/// Wakes a waker by reference.
Wakes a waker by reference.
Wakes a waker by reference .
unsafe fn wake_by_ref(ptr: *const ()) {
        let raw = Self::from_ptr(ptr);
        let mut state = (*raw.pdata).state.load(Ordering::Acquire);
        loop {
            // If the proc is completed or closed, it can't be woken.
            if state & (COMPLETED | CLOSED) != 0 {
                break;
            }
            // If the proc is already scheduled, we just need to synchronize with the thread that
            // will run the proc by "publishing" our current view of the memory.
            if state & SCHEDULED != 0 {
                // Update the state without actually modifying it.
                match (*raw.pdata).state.compare_exchange_weak(
                    state,
                    state,
                    Ordering::AcqRel,
                    Ordering::Acquire,
                ) {
                    Ok(_) => break,
                    Err(s) => state = s,
                }
            } else {
                // If the proc is not scheduled nor running, we'll need to schedule after waking.
                let new = if state & (SCHEDULED | RUNNING) == 0 {
                    (state | SCHEDULED) + REFERENCE
                } else {
                    state | SCHEDULED
                };
                // Mark the proc as scheduled.
                match (*raw.pdata).state.compare_exchange_weak(
                    state,
                    new,
                    Ordering::AcqRel,
                    Ordering::Acquire,
                ) {
                    Ok(_) => {
                        // If the proc is not scheduled nor running, now is the time to schedule.
                        if state & (SCHEDULED | RUNNING) == 0 {
                            // If the reference count overflowed, abort.
                            if state > isize::max_value() as usize {
                                std::process::abort();
                            }
                            // Schedule the proc.
                            let proc = LightProc {
                                raw_proc: NonNull::new_unchecked(ptr as *mut ()),
                            };
                            (*raw.schedule)(proc);
                        }
                        break;
                    }
                    Err(s) => state = s,
                }
            }
        }
    }
unsafe fn wake_by_ref ( ptr : * const ( ) ) { let raw = Self :: from_ptr ( ptr ) ; let mut state = ( * raw . pdata ) . state . load ( Ordering :: Acquire ) ; loop { // If the proc is completed or closed, it can't be woken. if state & ( COMPLETED | CLOSED ) != 0 { break ; } // If the proc is already scheduled, we just need to synchronize with the thread that // will run the proc by "publishing" our current view of the memory. if state & SCHEDULED != 0 { // Update the state without actually modifying it. match ( * raw . pdata ) . state . compare_exchange_weak ( state , state , Ordering :: AcqRel , Ordering :: Acquire , ) { Ok ( _ ) => break , Err ( s ) => state = s , } } else { // If the proc is not scheduled nor running, we'll need to schedule after waking. let new = if state & ( SCHEDULED | RUNNING ) == 0 { ( state | SCHEDULED ) + REFERENCE } else { state | SCHEDULED } ; // Mark the proc as scheduled. match ( * raw . pdata ) . state . compare_exchange_weak ( state , new , Ordering :: AcqRel , Ordering :: Acquire , ) { Ok ( _ ) => { // If the proc is not scheduled nor running, now is the time to schedule. if state & ( SCHEDULED | RUNNING ) == 0 { // If the reference count overflowed, abort. if state > isize :: max_value ( ) as usize { std :: process :: abort ( ) ; } // Schedule the proc. let proc = LightProc { raw_proc : NonNull :: new_unchecked ( ptr as * mut ( ) ) , } ; ( * raw . schedule ) ( proc ) ; } break ; } Err ( s ) => state = s , } } } }
Wakes a waker by reference.
Wakes a waker by reference .
ptr
*const ()
ptr
*const ()