in midst of refactor

This commit is contained in:
2024-04-29 21:46:42 +02:00
parent ed0d64d52e
commit aa3f7e99ab
221 changed files with 5431 additions and 685 deletions

View File

@@ -0,0 +1,11 @@
[package]
name = "orchid-extension"
version = "0.1.0"
edition = "2021"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[dependencies]
orchid-api = { version = "0.1.0", path = "../orchid-api" }
orchid-api-traits = { version = "0.1.0", path = "../orchid-api-traits" }
orchid-base = { version = "0.1.0", path = "../orchid-base" }

View File

@@ -0,0 +1,35 @@
use std::sync::atomic::{AtomicBool, Ordering};
use std::sync::Arc;
use orchid_api::proto::{ExtMsgSet, ExtensionHeader, HostExtNotif, HostExtReq, HostHeader};
use orchid_api_traits::{Decode, Encode};
use orchid_base::child::{recv_parent_msg, send_parent_msg};
use orchid_base::clone;
use orchid_base::intern::{init_replica, sweep_replica};
use orchid_base::reqnot::{ReqNot, Requester};
pub struct ExtensionData {}
pub fn main(data: &mut ExtensionData) {
HostHeader::decode(&mut &recv_parent_msg().unwrap()[..]);
let mut buf = Vec::new();
ExtensionHeader { systems: vec![] }.encode(&mut buf);
send_parent_msg(&buf).unwrap();
let exiting = Arc::new(AtomicBool::new(false));
let rn = ReqNot::<ExtMsgSet>::new(
|a, _| send_parent_msg(a).unwrap(),
clone!(exiting; move |n, _| match n {
HostExtNotif::Exit => exiting.store(true, Ordering::Relaxed),
_ => todo!(),
}),
|req| match req.req() {
HostExtReq::Ping(ping) => req.handle(ping, &()),
HostExtReq::Sweep(sweep) => req.handle(sweep, &sweep_replica()),
_ => todo!(),
},
);
init_replica(rn.clone().map());
while !exiting.load(Ordering::Relaxed) {
rn.receive(recv_parent_msg().unwrap())
}
}

View File

@@ -0,0 +1,30 @@
use std::sync::atomic::{AtomicBool, Ordering};
use std::sync::Arc;
use orchid_api::proto::{ExtMsgSet, ExtensionHeader, HostExtNotif, HostExtReq, HostHeader};
use orchid_api_traits::{Decode, Encode};
use ordered_float::NotNan;
use crate::child::{recv_parent_msg, send_parent_msg};
use crate::clone;
use crate::intern::{init_replica, sweep_replica};
use crate::reqnot::{ReqNot, Requester as _};
pub struct SystemParams {
deps: Vec<SystemHandle>,
}
pub struct SystemCtor {
deps: Vec<String>,
make: Box<dyn FnMut(SystemParams) -> System>,
name: String,
prio: NotNan<f64>,
dependencies: Vec<String>,
}
pub struct ExtensionData {
systems: Vec<SystemCtor>
}

View File

@@ -0,0 +1 @@
pub mod entrypoint;