pub fn signal_stop(&self, mut state: State) {
        use worker::Lifecycle::*;

        // Transition the worker state to signaled
        loop {
            let mut next = state;

            match state.lifecycle() {
                Shutdown => {
                    return;
                }
                Running | Sleeping => {}
                Notified | Signaled => {
                    // These two states imply that the worker is active, thus it
                    // will eventually see the shutdown signal, so we don't need
                    // to do anything.
                    //
                    // The worker is forced to see the shutdown signal
                    // eventually as:
                    //
                    // a) No more work will arrive
                    // b) The shutdown signal is stored as the head of the
                    // sleep, stack which will prevent the worker from going to
                    // sleep again.
                    return;
                }
            }

            next.set_lifecycle(Signaled);

            let actual = self
                .state
                .compare_and_swap(state.into(), next.into(), AcqRel)
                .into();

            if actual == state {
                break;
            }

            state = actual;
        }

        // Wakeup the worker
        self.unpark();
    }
/// Signals to the worker that it should stop
///
/// `state` is the last observed state for the worker. This allows skipping
/// the initial load from the state atomic.
///
/// # Return
///
/// Returns `Ok` when the worker was successfully signaled.
///
/// Returns `Err` if the worker has already terminated.
Signals to the worker that it should stop
`state` is the last observed state for the worker. This allows skipping
the initial load from the state atomic.
Signals to the worker that it should stop ` state ` is the last observed state for the worker . This allows skipping the initial load from the state atomic .
pub fn signal_stop(&self, mut state: State) {
        use worker::Lifecycle::*;
        // Transition the worker state to signaled
        loop {
            let mut next = state;
            match state.lifecycle() {
                Shutdown => {
                    return;
                }
                Running | Sleeping => {}
                Notified | Signaled => {
                    // These two states imply that the worker is active, thus it
                    // will eventually see the shutdown signal, so we don't need
                    // to do anything.
                    //
                    // The worker is forced to see the shutdown signal
                    // eventually as:
                    //
                    // a) No more work will arrive
                    // b) The shutdown signal is stored as the head of the
                    // sleep, stack which will prevent the worker from going to
                    // sleep again.
                    return;
                }
            }
            next.set_lifecycle(Signaled);
            let actual = self
                .state
                .compare_and_swap(state.into(), next.into(), AcqRel)
                .into();
            if actual == state {
                break;
            }
            state = actual;
        }
        // Wakeup the worker
        self.unpark();
    }
pub fn signal_stop ( & self , mut state : State ) { use worker :: Lifecycle :: * ; // Transition the worker state to signaled loop { let mut next = state ; match state . lifecycle ( ) { Shutdown => { return ; } Running | Sleeping => { } Notified | Signaled => { // These two states imply that the worker is active, thus it // will eventually see the shutdown signal, so we don't need // to do anything. // // The worker is forced to see the shutdown signal // eventually as: // // a) No more work will arrive // b) The shutdown signal is stored as the head of the // sleep, stack which will prevent the worker from going to // sleep again. return ; } } next . set_lifecycle ( Signaled ) ; let actual = self . state . compare_and_swap ( state . into ( ) , next . into ( ) , AcqRel ) . into ( ) ; if actual == state { break ; } state = actual ; } // Wakeup the worker self . unpark ( ) ; }
Signals to the worker that it should stop
`state` is the last observed state for the worker.
Signals to the worker that it should stop ` state ` is the last observed state for the worker .
Returns `Ok` when the worker was successfully signaled.

Returns `Err` if the worker has already terminated.
Returns ` Ok ` when the worker was successfully signaled . Returns ` Err ` if the worker has already terminated .
&self
state
State