fn stop(&self, killed: bool) {
        let mut inner = self.inner.lock();
        if inner.state == ThreadState::Dead {
            return;
        }
        if killed {
            inner.killed = true;
        }
        if inner.state == ThreadState::Dying {
            if killed {
                if let Some(killer) = inner.killer.take() {
                    // It's ok to ignore the error since the other end could be closed
                    killer.send(()).ok();
                }
            }
            return;
        }
        inner.change_state(ThreadState::Dying, &self.base);
        if let Some(waker) = inner.waker.take() {
            waker.wake();
        }
        // For blocking thread, use the killer
        if let Some(killer) = inner.killer.take() {
            // It's ok to ignore the error since the other end could be closed
            killer.send(()).ok();
        }
    }
/// Stop the thread. Internal implementation of `exit` and `kill`.
///
/// The thread do not terminate immediately when stopped. It is just made dying.
/// It will terminate after some cleanups (when `terminate` are called **explicitly** by upper layer).
Stop the thread. Internal implementation of `exit` and `kill`.
The thread do not terminate immediately when stopped. It is just made dying.
It will terminate after some cleanups (when `terminate` are called **explicitly** by upper layer).
Stop the thread . Internal implementation of ` exit ` and ` kill ` . The thread do not terminate immediately when stopped . It is just made dying . It will terminate after some cleanups ( when ` terminate ` are called ** explicitly ** by upper layer ) .
fn stop(&self, killed: bool) {
        let mut inner = self.inner.lock();
        if inner.state == ThreadState::Dead {
            return;
        }
        if killed {
            inner.killed = true;
        }
        if inner.state == ThreadState::Dying {
            if killed {
                if let Some(killer) = inner.killer.take() {
                    // It's ok to ignore the error since the other end could be closed
                    killer.send(()).ok();
                }
            }
            return;
        }
        inner.change_state(ThreadState::Dying, &self.base);
        if let Some(waker) = inner.waker.take() {
            waker.wake();
        }
        // For blocking thread, use the killer
        if let Some(killer) = inner.killer.take() {
            // It's ok to ignore the error since the other end could be closed
            killer.send(()).ok();
        }
    }
fn stop ( & self , killed : bool ) { let mut inner = self . inner . lock ( ) ; if inner . state == ThreadState :: Dead { return ; } if killed { inner . killed = true ; } if inner . state == ThreadState :: Dying { if killed { if let Some ( killer ) = inner . killer . take ( ) { // It's ok to ignore the error since the other end could be closed killer . send ( ( ) ) . ok ( ) ; } } return ; } inner . change_state ( ThreadState :: Dying , & self . base ) ; if let Some ( waker ) = inner . waker . take ( ) { waker . wake ( ) ; } // For blocking thread, use the killer if let Some ( killer ) = inner . killer . take ( ) { // It's ok to ignore the error since the other end could be closed killer . send ( ( ) ) . ok ( ) ; } }
Stop the thread.
Stop the thread .
&self
killed
bool
&self
killed
bool