From e13cc14a618a1ba817f8d667ea333133028f7e47 Mon Sep 17 00:00:00 2001 From: ame Date: Tue, 25 Nov 2025 03:44:22 -0600 Subject: more consistent locals, better test printing --- src/thread.c | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) (limited to 'src/thread.c') diff --git a/src/thread.c b/src/thread.c index fbf5f01..f166c3f 100644 --- a/src/thread.c +++ b/src/thread.c @@ -203,11 +203,15 @@ int _thread_await(lua_State* L){ pthread_mutex_lock(&*info->lock); if(info->return_count == 0) return 0; + lua_getglobal(L, "_locals"); + int old_locals = lua_gettop(L); + + lua_getglobal(info->L, "_stored_locals"); lua_getglobal(info->L, "_res_locals"); + luaI_jointable(info->L); luaI_deepcopy(info->L, L, SKIP_LOCALS | STRIP_GC); - env_table(L, 0); + //env_table(L, 0); - luaI_jointable(L); lua_setglobal(L, "_locals"); lua_getglobal(info->L, "_return_table"); @@ -219,7 +223,7 @@ int _thread_await(lua_State* L){ luaI_deepcopy(info->L, L, STRIP_GC); } - lua_pushnil(L); + lua_pushvalue(L, old_locals); lua_setglobal(L, "_locals"); pthread_mutex_unlock(&*info->lock); @@ -300,6 +304,9 @@ int l_async(lua_State* oL){ luaI_copyvars(oL, L); luaL_openlibs(L); + lua_getglobal(L, "_locals"); + lua_setglobal(L, "_stored_locals"); + struct thread_info* args = calloc(1, sizeof * args); args->L = L; args->lock = malloc(sizeof * args->lock); -- cgit v1.2.3