INNER CODE UNIT · Rust

close_session

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

    pub async fn close_session(&self, session_id: SessionId) -> Result<(), AcpError> {
        self.request(|reply| Command::Close(session_id, reply))
            .await
    }

    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();

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…