Add some different debugging

This commit is contained in:
Filip Tibell 2023-08-20 14:11:48 -05:00
parent a8db74d40d
commit 7e7cfd7cd0
3 changed files with 9 additions and 7 deletions

View file

@ -136,9 +136,7 @@ impl<'lua> RequireContext<'lua> {
.lua
.registry_value::<Vec<LuaValue>>(k)
.expect("Missing require result in lua registry");
let multi = LuaMultiValue::from_vec(multi_vec);
println!("Got multi value from cache: {multi:?}");
Ok(multi)
Ok(LuaMultiValue::from_vec(multi_vec))
}
}
}
@ -193,13 +191,13 @@ impl<'lua> RequireContext<'lua> {
// Schedule the thread to run, wait for it to finish running
let thread_id = sched.push_back(file_thread, ())?;
println!("Waiting for thread with id {thread_id:?}");
let thread_res = sched.wait_for_thread(thread_id).await;
// Return the result of the thread, storing any lua value(s) in the registry
match thread_res {
Err(e) => Err(e),
Ok(v) => {
println!("Got multi value from require: {v:?}");
let multi_vec = v.into_vec();
let multi_key = self
.lua
@ -260,8 +258,6 @@ impl<'lua> RequireContext<'lua> {
.expect("Pending require broadcaster was unexpectedly removed");
broadcast_tx.send(()).ok();
println!("Got return value from require: {load_val:?}");
load_val
}

View file

@ -42,6 +42,7 @@ where
// Resume the thread, ensuring that the schedulers
// current thread id is set correctly for error catching
println!("Resuming thread with id {thread_id:?}");
self.state.set_current_thread_id(Some(thread_id));
let res = thread.resume::<_, LuaMultiValue>(args);
self.state.set_current_thread_id(None);
@ -56,7 +57,8 @@ where
self.lua.emit_error(err.clone());
}
// Send results of resuming this thread to any listeners
// If the thread has finished running completely,
// send results of final resume to any listeners
if let Some(sender) = self.thread_senders.borrow_mut().remove(&thread_id) {
if sender.receiver_count() > 0 {
let stored = match res {

View file

@ -2,10 +2,14 @@ local task = require("@lune/task")
print("Requiring 1")
local module1 = require("./modules/async")
print("Required 1")
print("Requiring 2")
local module2 = require("./modules/async")
print("Required 2")
print("Waiting")
task.wait(1)
print("Waited")
assert(type(module1) == "table", "Required module1 did not return a table")
assert(module1.Foo == "Bar", "Required module1 did not contain correct values")