INNER CODE UNIT · Rust

shutdown

xuzhougeng/wisp-science · crates/wisp-acp/src/lib.rs:398

    pub async fn shutdown(&self, grace: Duration) {
        let _ = self.command_tx.send(Command::Shutdown);
        let actor = self.actor.lock().expect("ACP actor mutex poisoned").take();
        if let Some(mut actor) = actor {
            if tokio::time::timeout(grace, &mut actor).await.is_err() {
                actor.abort();
                let _ = actor.await;
            }
        }
    }

    async fn request<T>(&self, command: impl FnOnce(Reply<T>) -> Command) -> Result<T, AcpError> {
        let (reply_tx, reply_rx) = oneshot::channel();
        self.command_tx
            .send(command(reply_tx))
            .map_err(|_| AcpError::Closed)?;
        reply_rx.await.map_err(|_| AcpError::Closed)?
    }

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…