added a new test for comm

This commit is contained in:
2026-04-24 02:40:05 +00:00
parent 0bc7097c88
commit 759497ee70
7 changed files with 234 additions and 210 deletions

View File

@@ -15,7 +15,7 @@ use itertools::Itertools;
use orchid_api_traits::{Decode, Encode, Request, UnderRoot, enc_vec};
use orchid_async_utils::{Handle, JoinError, to_task};
use orchid_base::{
Client, ClientExt, CommCtx, Comment, MsgReader, MsgReaderExt, ReqHandleExt, ReqReaderExt,
Client, ClientExt, CommCx, Comment, IoComm, MsgReader, MsgReaderExt, ReqHandleExt, ReqReaderExt,
Snippet, Sym, TokenVariant, Witness, char_filter_match, char_filter_union, es, io_comm, is, log,
mk_char_filter, try_with_reporter, ttv_from_api, with_interner, with_logger, with_stash,
};
@@ -37,7 +37,7 @@ use crate::{
task_local::task_local! {
static CLIENT: Rc<dyn Client>;
static CTX: Rc<RefCell<Option<CommCtx>>>;
static CTX: Rc<RefCell<Option<CommCx>>>;
}
fn get_client() -> Rc<dyn Client> { CLIENT.get() }
@@ -51,7 +51,7 @@ pub async fn exit() {
/// Set the client used for global [request] and [notify] functions within the
/// runtime of this future
pub async fn with_comm<F: Future>(c: Rc<dyn Client>, ctx: CommCtx, fut: F) -> F::Output {
pub async fn with_comm<F: Future>(c: Rc<dyn Client>, ctx: CommCx, fut: F) -> F::Output {
CLIENT.scope(c, CTX.scope(Rc::new(RefCell::new(Some(ctx))), fut)).await
}
@@ -194,9 +194,9 @@ impl ExtensionBuilder {
ctx.output.as_mut().flush().await.unwrap();
let logger1 = LoggerImpl::from_api(&host_header.logger);
let logger2 = logger1.clone();
let (client, comm_ctx, extension_srv) = io_comm(ctx.output, ctx.input);
let IoComm { client, cx: comm_ctx, srv } = io_comm(ctx.output, ctx.input);
// this future will be ready once the extension cleanly exits
let extension_fut = extension_srv.listen(
let extension_fut = srv.listen(
async |n: Box<dyn MsgReader<'_>>| {
let notif = n.read().await.unwrap();
match notif {