aboutsummaryrefslogtreecommitdiff
path: root/lstate.c
diff options
context:
space:
mode:
authorRoberto Ierusalimschy <roberto@inf.puc-rio.br>2025-06-12 11:15:09 -0300
committerRoberto Ierusalimschy <roberto@inf.puc-rio.br>2025-06-12 11:15:09 -0300
commitfd897027f19288ce2cb0249cb8c1818e2f3f1c4c (patch)
tree7fd131ca204c4100a24157405eda4239d2155a46 /lstate.c
parentd05fe48bfdd89956c0ebd115dca0fb115aa28dd6 (diff)
downloadlua-fd897027f19288ce2cb0249cb8c1818e2f3f1c4c.tar.gz
lua-fd897027f19288ce2cb0249cb8c1818e2f3f1c4c.tar.bz2
lua-fd897027f19288ce2cb0249cb8c1818e2f3f1c4c.zip
A coroutine can close itself
A call to close itself will close all its to-be-closed variables and return to the resume that (re)started the coroutine.
Diffstat (limited to 'lstate.c')
-rw-r--r--lstate.c2
1 files changed, 2 insertions, 0 deletions
diff --git a/lstate.c b/lstate.c
index 20ed838f..70a11aae 100644
--- a/lstate.c
+++ b/lstate.c
@@ -326,6 +326,8 @@ LUA_API int lua_closethread (lua_State *L, lua_State *from) {
326 lua_lock(L); 326 lua_lock(L);
327 L->nCcalls = (from) ? getCcalls(from) : 0; 327 L->nCcalls = (from) ? getCcalls(from) : 0;
328 status = luaE_resetthread(L, L->status); 328 status = luaE_resetthread(L, L->status);
329 if (L == from) /* closing itself? */
330 luaD_throwbaselevel(L, status);
329 lua_unlock(L); 331 lua_unlock(L);
330 return APIstatus(status); 332 return APIstatus(status);
331} 333}