mirror of
https://github.com/lune-org/mlua-luau-scheduler.git
synced 2025-04-10 21:40:55 +01:00
fix: exit codes are of u8
, not i32
This commit is contained in:
parent
22d15b3649
commit
82c8b902e0
4 changed files with 8 additions and 8 deletions
|
@ -4,7 +4,7 @@ use event_listener::Event;
|
||||||
|
|
||||||
#[derive(Debug, Clone)]
|
#[derive(Debug, Clone)]
|
||||||
pub(crate) struct Exit {
|
pub(crate) struct Exit {
|
||||||
code: Rc<Cell<Option<i32>>>,
|
code: Rc<Cell<Option<u8>>>,
|
||||||
event: Rc<Event>,
|
event: Rc<Event>,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -16,12 +16,12 @@ impl Exit {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn set(&self, code: i32) {
|
pub fn set(&self, code: u8) {
|
||||||
self.code.set(Some(code));
|
self.code.set(Some(code));
|
||||||
self.event.notify(usize::MAX);
|
self.event.notify(usize::MAX);
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn get(&self) -> Option<i32> {
|
pub fn get(&self) -> Option<u8> {
|
||||||
self.code.get()
|
self.code.get()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -230,7 +230,7 @@ impl<'lua> Functions<'lua> {
|
||||||
let exit_env = lua.create_table_from(vec![
|
let exit_env = lua.create_table_from(vec![
|
||||||
(
|
(
|
||||||
"exit",
|
"exit",
|
||||||
lua.create_function(|lua, code: Option<i32>| {
|
lua.create_function(|lua, code: Option<u8>| {
|
||||||
let _span = tracing::trace_span!("Scheduler::fn_exit").entered();
|
let _span = tracing::trace_span!("Scheduler::fn_exit").entered();
|
||||||
let code = code.unwrap_or_default();
|
let code = code.unwrap_or_default();
|
||||||
lua.set_exit_code(code);
|
lua.set_exit_code(code);
|
||||||
|
|
|
@ -167,7 +167,7 @@ impl<'lua> Scheduler<'lua> {
|
||||||
Gets the exit code for this scheduler, if one has been set.
|
Gets the exit code for this scheduler, if one has been set.
|
||||||
*/
|
*/
|
||||||
#[must_use]
|
#[must_use]
|
||||||
pub fn get_exit_code(&self) -> Option<i32> {
|
pub fn get_exit_code(&self) -> Option<u8> {
|
||||||
self.exit.get()
|
self.exit.get()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -176,7 +176,7 @@ impl<'lua> Scheduler<'lua> {
|
||||||
|
|
||||||
This will cause [`Scheduler::run`] to exit immediately.
|
This will cause [`Scheduler::run`] to exit immediately.
|
||||||
*/
|
*/
|
||||||
pub fn set_exit_code(&self, code: i32) {
|
pub fn set_exit_code(&self, code: u8) {
|
||||||
self.exit.set(code);
|
self.exit.set(code);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -80,7 +80,7 @@ pub trait LuaSchedulerExt<'lua> {
|
||||||
|
|
||||||
Panics if called outside of a running [`Scheduler`].
|
Panics if called outside of a running [`Scheduler`].
|
||||||
*/
|
*/
|
||||||
fn set_exit_code(&self, code: i32);
|
fn set_exit_code(&self, code: u8);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Pushes (spawns) a lua thread to the **front** of the current scheduler.
|
Pushes (spawns) a lua thread to the **front** of the current scheduler.
|
||||||
|
@ -281,7 +281,7 @@ pub trait LuaSpawnExt<'lua> {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'lua> LuaSchedulerExt<'lua> for Lua {
|
impl<'lua> LuaSchedulerExt<'lua> for Lua {
|
||||||
fn set_exit_code(&self, code: i32) {
|
fn set_exit_code(&self, code: u8) {
|
||||||
let exit = self
|
let exit = self
|
||||||
.app_data_ref::<Exit>()
|
.app_data_ref::<Exit>()
|
||||||
.expect("exit code can only be set from within an active scheduler");
|
.expect("exit code can only be set from within an active scheduler");
|
||||||
|
|
Loading…
Add table
Reference in a new issue