mirror of
https://github.com/lune-org/mlua-luau-scheduler.git
synced 2025-04-10 21:40:55 +01:00
Error message does not need thread id
This commit is contained in:
parent
c920d31126
commit
a4599618de
2 changed files with 4 additions and 5 deletions
|
@ -103,8 +103,7 @@ fn main_lua_task(mut rx: MessageReceiver, tx: MessageSender, stats: Stats) -> Lu
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
if let Err(e) = thread.resume::<_, ()>(args) {
|
if let Err(e) = thread.resume::<_, ()>(args) {
|
||||||
tx.send(Message::Error(thread_id, Box::new(e)))
|
tx.send(Message::WriteError(e)).unwrap();
|
||||||
.expect("failed to send error to async task");
|
|
||||||
} else if thread.status() == LuaThreadStatus::Resumable {
|
} else if thread.status() == LuaThreadStatus::Resumable {
|
||||||
yielded_threads.insert(thread_id, thread);
|
yielded_threads.insert(thread_id, thread);
|
||||||
}
|
}
|
||||||
|
@ -165,7 +164,7 @@ async fn main_async_task(
|
||||||
let process_message = |message| {
|
let process_message = |message| {
|
||||||
match message {
|
match message {
|
||||||
Message::Sleep(_, _, _) => stats.incr(StatsCounter::ThreadSlept),
|
Message::Sleep(_, _, _) => stats.incr(StatsCounter::ThreadSlept),
|
||||||
Message::Error(_, _) => stats.incr(StatsCounter::ThreadErrored),
|
Message::WriteError(_) => stats.incr(StatsCounter::ThreadErrored),
|
||||||
Message::WriteStdout(_) => stats.incr(StatsCounter::WriteStdout),
|
Message::WriteStdout(_) => stats.incr(StatsCounter::WriteStdout),
|
||||||
Message::WriteStderr(_) => stats.incr(StatsCounter::WriteStderr),
|
Message::WriteStderr(_) => stats.incr(StatsCounter::WriteStderr),
|
||||||
_ => unreachable!(),
|
_ => unreachable!(),
|
||||||
|
@ -180,7 +179,7 @@ async fn main_async_task(
|
||||||
tx.send(Message::Resume(thread_id, Ok(AsyncValues::from(elapsed))))
|
tx.send(Message::Resume(thread_id, Ok(AsyncValues::from(elapsed))))
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
Message::Error(_, e) => {
|
Message::WriteError(e) => {
|
||||||
forward_stderr(b"Lua error: ".to_vec());
|
forward_stderr(b"Lua error: ".to_vec());
|
||||||
forward_stderr(e.to_string().as_bytes().to_vec());
|
forward_stderr(e.to_string().as_bytes().to_vec());
|
||||||
}
|
}
|
||||||
|
|
|
@ -15,7 +15,7 @@ pub enum Message {
|
||||||
Resume(ThreadId, LuaResult<AsyncValues>),
|
Resume(ThreadId, LuaResult<AsyncValues>),
|
||||||
Cancel(ThreadId),
|
Cancel(ThreadId),
|
||||||
Sleep(ThreadId, Instant, Duration),
|
Sleep(ThreadId, Instant, Duration),
|
||||||
Error(ThreadId, Box<LuaError>),
|
WriteError(LuaError),
|
||||||
WriteStdout(Vec<u8>),
|
WriteStdout(Vec<u8>),
|
||||||
WriteStderr(Vec<u8>),
|
WriteStderr(Vec<u8>),
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue