diff --git a/src/lib/globals/task.rs b/src/lib/globals/task.rs index e4a3ad1..43c6396 100644 --- a/src/lib/globals/task.rs +++ b/src/lib/globals/task.rs @@ -53,7 +53,10 @@ async fn task_cancel<'a>(lua: &'a Lua, thread: LuaThread<'a>) -> LuaResult<()> { Ok(()) } -async fn task_defer<'a>(lua: &'a Lua, tof: LuaValue<'a>) -> LuaResult> { +async fn task_defer<'a>( + lua: &'a Lua, + (tof, _args): (LuaValue<'a>, LuaMultiValue<'a>), +) -> LuaResult> { // Spawn a new detached task using a lua reference that we can use inside of our task let task_lua = lua.app_data_ref::>().unwrap().upgrade().unwrap(); let task_thread = tof_to_thread(lua, tof)?; @@ -64,6 +67,7 @@ async fn task_defer<'a>(lua: &'a Lua, tof: LuaValue<'a>) -> LuaResult(()).await?; } + task_lua.remove_registry_value(task_thread_key)?; Ok(()) }) .await?; @@ -72,7 +76,7 @@ async fn task_defer<'a>(lua: &'a Lua, tof: LuaValue<'a>) -> LuaResult( lua: &'a Lua, - (duration, tof): (Option, LuaValue<'a>), + (duration, tof, _args): (Option, LuaValue<'a>, LuaMultiValue<'a>), ) -> LuaResult> { // Spawn a new detached task using a lua reference that we can use inside of our task let task_lua = lua.app_data_ref::>().unwrap().upgrade().unwrap(); @@ -85,13 +89,17 @@ async fn task_delay<'a>( if thread.status() == LuaThreadStatus::Resumable { thread.into_async::<_, LuaMultiValue>(()).await?; } + task_lua.remove_registry_value(task_thread_key)?; Ok(()) }) .await?; Ok(lua_thread_to_return) } -async fn task_spawn<'a>(lua: &'a Lua, tof: LuaValue<'a>) -> LuaResult> { +async fn task_spawn<'a>( + lua: &'a Lua, + (tof, _args): (LuaValue<'a>, LuaMultiValue<'a>), +) -> LuaResult> { // Spawn a new detached task using a lua reference that we can use inside of our task let task_lua = lua.app_data_ref::>().unwrap().upgrade().unwrap(); let task_thread = tof_to_thread(lua, tof)?; @@ -102,6 +110,7 @@ async fn task_spawn<'a>(lua: &'a Lua, tof: LuaValue<'a>) -> LuaResult(()).await?; } + task_lua.remove_registry_value(task_thread_key)?; Ok(()) }) .await?;