pub fn shutdown(&self, now: bool, purge_queue: bool) {
        let mut state: State = self.state.load(Acquire).into();

        trace!("shutdown; state={:?}", state);

        // For now, this must be true
        debug_assert!(!purge_queue || now);

        // Start by setting the shutdown flag
        loop {
            let mut next = state;

            let num_futures = next.num_futures();

            if next.lifecycle() == Lifecycle::ShutdownNow {
                // Already transitioned to shutting down state

                if !purge_queue || num_futures == 0 {
                    // Nothing more to do
                    return;
                }

                // The queue must be purged
                debug_assert!(purge_queue);
                next.clear_num_futures();
            } else {
                next.set_lifecycle(if now || num_futures == 0 {
                    // If already idle, always transition to shutdown now.
                    Lifecycle::ShutdownNow
                } else {
                    Lifecycle::ShutdownOnIdle
                });

                if purge_queue {
                    next.clear_num_futures();
                }
            }

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

            if state == actual {
                state = next;
                break;
            }

            state = actual;
        }

        trace!("  -> transitioned to shutdown");

        // Only transition to terminate if there are no futures currently on the
        // pool
        if state.num_futures() != 0 {
            return;
        }

        self.terminate_sleeping_workers();
    }
/// Start shutting down the pool. This means that no new futures will be
/// accepted.
Start shutting down the pool. This means that no new futures will be
accepted.
Start shutting down the pool . This means that no new futures will be accepted .
pub fn shutdown(&self, now: bool, purge_queue: bool) {
        let mut state: State = self.state.load(Acquire).into();
        trace!("shutdown; state={:?}", state);
        // For now, this must be true
        debug_assert!(!purge_queue || now);
        // Start by setting the shutdown flag
        loop {
            let mut next = state;
            let num_futures = next.num_futures();
            if next.lifecycle() == Lifecycle::ShutdownNow {
                // Already transitioned to shutting down state
                if !purge_queue || num_futures == 0 {
                    // Nothing more to do
                    return;
                }
                // The queue must be purged
                debug_assert!(purge_queue);
                next.clear_num_futures();
            } else {
                next.set_lifecycle(if now || num_futures == 0 {
                    // If already idle, always transition to shutdown now.
                    Lifecycle::ShutdownNow
                } else {
                    Lifecycle::ShutdownOnIdle
                });
                if purge_queue {
                    next.clear_num_futures();
                }
            }
            let actual = self
                .state
                .compare_and_swap(state.into(), next.into(), AcqRel)
                .into();
            if state == actual {
                state = next;
                break;
            }
            state = actual;
        }
        trace!("  -> transitioned to shutdown");
        // Only transition to terminate if there are no futures currently on the
        // pool
        if state.num_futures() != 0 {
            return;
        }
        self.terminate_sleeping_workers();
    }
pub fn shutdown ( & self , now : bool , purge_queue : bool ) { let mut state : State = self . state . load ( Acquire ) . into ( ) ; trace ! ( " " state ) ; // For now, this must be true debug_assert ! ( purge_queue now ) ; // Start by setting the shutdown flag loop { let mut next = state ; let num_futures = next . num_futures ( ) ; if next . lifecycle ( ) == Lifecycle :: ShutdownNow { // Already transitioned to shutting down state if ! purge_queue || num_futures == 0 { // Nothing more to do return ; } // The queue must be purged debug_assert ! ( purge_queue ) ; next . clear_num_futures ( ) ; } else { next . set_lifecycle ( if now || num_futures == 0 { // If already idle, always transition to shutdown now. Lifecycle :: ShutdownNow } else { Lifecycle :: ShutdownOnIdle } ) ; if purge_queue { next . clear_num_futures ( ) ; } } let actual = self . state . compare_and_swap ( state . into ( ) , next . into ( ) , AcqRel ) . into ( ) ; if state == actual { state = next ; break ; } state = actual ; } trace ! ( " " ) ; // Only transition to terminate if there are no futures currently on the // pool if state . num_futures ( ) != 0 { return ; } self . terminate_sleeping_workers ( ) ; }
Start shutting down the pool.
Start shutting down the pool .
&self
now
bool
purge_queue
bool