Compare commits

..

No commits in common. "1158821affde4667866cc999b1c18b7dda1eb634" and "33b7f78038f503598b23f64e76786f4583e5df28" have entirely different histories.

6 changed files with 10 additions and 29 deletions

View File

@ -1,7 +1,7 @@
&&& buffers: shared memory with Rust
& use types that are all either empty or any
box console = []
box input = nil
box input = ""
box fetch_outbox = ""
box fetch_inbox = ()
box keys_down = []
@ -1299,14 +1299,14 @@ fn fetch {
fn input_reader! {
(pid as :keyword) -> {
if not (unbox (input))
if empty? (unbox (input))
then {
yield! ()
input_reader! (pid)
}
else {
send (pid, (:reply, unbox (input)))
store! (input, nil)
store! (input, "")
}
}
}

View File

@ -9,7 +9,6 @@ let ludus_commands = []
let ludus_result = null
let code = null
let running = false
let ready = false
let io_interval_id = null
worker.onmessage = handle_messages
@ -51,10 +50,6 @@ async function handle_messages (e) {
console.log("Main: js responds => ", text)
outbox.push({verb: "Fetch", data: [msg.data, res.status, text]})
}
case "Ready": {
console.log("Main: ludus is ready")
ready = true
}
}
}
}
@ -62,13 +57,10 @@ async function handle_messages (e) {
function io_poller () {
if (io_interval_id && !running) {
// flush the outbox one last time
// (presumably, with the kill message)
worker.postMessage(outbox)
// cancel the poller
clearInterval(io_interval_id)
outbox = []
}
if (ready && running) {
} else {
worker.postMessage(outbox)
outbox = []
}
@ -81,28 +73,23 @@ function start_io_polling () {
// runs a ludus script; does not return the result
// the result must be explicitly polled with `result`
export function run (source) {
if (running) {
return "TODO: handle this? should not be running"
}
if (running) "TODO: handle this? should not be running"
running = true
ready = false
result = null
code = source
worker.postMessage([{verb: "Run", data: source}])
outbox = []
outbox = [{verb: "Run", data: source}]
start_io_polling()
}
// tells if the ludus script is still running
export function is_running() {
return running && ready
return running
}
// kills a ludus script
export function kill () {
running = false
outbox.push({verb: "Kill"})
console.log("Main: Killed Ludus")
}
// sends text into ludus (status: not working)

View File

@ -328,7 +328,7 @@ function __wbg_get_imports() {
const ret = false;
return ret;
};
imports.wbg.__wbindgen_closure_wrapper984 = function(arg0, arg1, arg2) {
imports.wbg.__wbindgen_closure_wrapper985 = function(arg0, arg1, arg2) {
const ret = makeMutClosure(arg0, arg1, 329, __wbg_adapter_20);
return ret;
};

Binary file not shown.

View File

@ -33,7 +33,6 @@ pub enum MsgOut {
Commands(Commands),
Fetch(Url),
Complete(FinalValue),
Ready
}
impl std::fmt::Display for MsgOut {
@ -69,9 +68,6 @@ impl MsgOut {
let json_lines = format!("\"{json_lines}\"");
make_json_payload("Console", json_lines)
}
MsgOut::Ready => {
make_json_payload("Ready", "\"null\"".to_string())
}
}
}
}

View File

@ -455,16 +455,14 @@ impl World {
_ => todo!()
}
}
}
}
pub async fn run(&mut self) {
self.activate_main();
do_io(vec![MsgOut::Ready]).await;
loop {
self.maybe_do_io().await;
if self.kill_signal {
let mut outbox = self.flush_buffers();
outbox.push(MsgOut::Complete(Err(Panic::Str("ludus killed by user"))));
let outbox = self.flush_buffers();
do_io(outbox).await;
return;
}