我想检查 lua_state 是否已关闭。我该如何检查?我使用这个库作为 c++ lua 嵌入器:https://github.com/lua/lua
答案 0 :(得分:0)
在 lua 中关闭 lau_State
会释放所有分配的内存,包括 lua_State
本身。
来自 Lua 5.4.2 源代码:
static void close_state (lua_State *L) {
global_State *g = G(L);
...
(*g->frealloc)(g->ud, fromstate(L), sizeof(LG), 0); /* free main block */
}
表示关闭的 lua_State
指向无效内存。
因此,由您来管理线程或异步任务中的 open
/closed
状态。