Decided to eradicate Send/Sync dependence, broke everything as a result. Should resume from interner

This commit is contained in:
2025-01-20 22:22:33 +01:00
parent 5859b41a7c
commit 1974c69019
25 changed files with 733 additions and 784 deletions

View File

@@ -1,16 +1,22 @@
use std::any::TypeId;
use std::future::Future;
use std::num::NonZero;
use std::sync::Arc;
use futures::FutureExt;
use futures::future::LocalBoxFuture;
use futures::task::LocalSpawn;
use hashbrown::HashMap;
use orchid_api_traits::{Coding, Decode};
use orchid_base::boxed_iter::BoxedIter;
use orchid_base::id_store::IdStore;
use orchid_base::interner::Tok;
use orchid_base::logging::Logger;
use orchid_base::reqnot::{Receipt, ReqNot};
use crate::api;
use crate::atom::{AtomCtx, AtomDynfo, AtomicFeatures, ForeignAtom, TypAtom, get_info};
use crate::atom_owned::{DynOwnedAtom, ObjStore};
use crate::entrypoint::ExtReq;
use crate::fs::DeclFs;
use crate::func_atom::Fun;
@@ -77,7 +83,7 @@ pub trait System: Send + Sync + SystemCard + 'static {
fn vfs() -> DeclFs;
fn lexers() -> Vec<LexerObj>;
fn parsers() -> Vec<ParserObj>;
fn request(hand: ExtReq, req: Self::Req) -> Receipt;
fn request<'a>(hand: ExtReq<'a>, req: Self::Req) -> impl Future<Output = Receipt<'a>>;
}
pub trait DynSystem: Send + Sync + DynSystemCard + 'static {
@@ -85,7 +91,7 @@ pub trait DynSystem: Send + Sync + DynSystemCard + 'static {
fn dyn_vfs(&self) -> DeclFs;
fn dyn_lexers(&self) -> Vec<LexerObj>;
fn dyn_parsers(&self) -> Vec<ParserObj>;
fn dyn_request(&self, hand: ExtReq, req: Vec<u8>) -> Receipt;
fn dyn_request<'a>(&'a self, hand: ExtReq<'a>, req: Vec<u8>) -> LocalBoxFuture<'a, Receipt<'a>>;
fn card(&self) -> &dyn DynSystemCard;
}
@@ -94,8 +100,8 @@ impl<T: System> DynSystem for T {
fn dyn_vfs(&self) -> DeclFs { Self::vfs() }
fn dyn_lexers(&self) -> Vec<LexerObj> { Self::lexers() }
fn dyn_parsers(&self) -> Vec<ParserObj> { Self::parsers() }
fn dyn_request(&self, hand: ExtReq, req: Vec<u8>) -> Receipt {
Self::request(hand, <Self as SystemCard>::Req::decode(&mut &req[..]))
fn dyn_request<'a>(&'a self, hand: ExtReq<'a>, req: Vec<u8>) -> LocalBoxFuture<'a, Receipt<'a>> {
Self::request(hand, <Self as SystemCard>::Req::decode(&mut &req[..])).boxed_local()
}
fn card(&self) -> &dyn DynSystemCard { self }
}
@@ -119,17 +125,9 @@ pub fn downcast_atom<A: AtomicFeatures>(foreign: ForeignAtom) -> Result<TypAtom<
#[derive(Clone)]
pub struct SysCtx {
pub reqnot: ReqNot<api::ExtMsgSet>,
pub spawner: Arc<dyn LocalSpawn>,
pub id: api::SysId,
pub cted: CtedObj,
pub logger: Arc<Logger>,
}
impl SysCtx {
pub fn new(
id: api::SysId,
cted: &CtedObj,
logger: &Arc<Logger>,
reqnot: ReqNot<api::ExtMsgSet>,
) -> Self {
Self { cted: cted.clone(), id, logger: logger.clone(), reqnot }
}
pub obj_store: ObjStore,
}