MCPcopy Create free account
hub / github.com/EmmyLua/EmmyLuaDebugger / lua_newthread

Function lua_newthread

third-party/lua-5.5.0/src/lstate.c:273–297  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

271
272
273LUA_API lua_State *lua_newthread (lua_State *L) {
274 global_State *g = G(L);
275 GCObject *o;
276 lua_State *L1;
277 lua_lock(L);
278 luaC_checkGC(L);
279 /* create new thread */
280 o = luaC_newobjdt(L, LUA_TTHREAD, sizeof(LX), offsetof(LX, l));
281 L1 = gco2th(o);
282 /* anchor it on L stack */
283 setthvalue2s(L, L->top.p, L1);
284 api_incr_top(L);
285 preinit_thread(L1, g);
286 L1->hookmask = L->hookmask;
287 L1->basehookcount = L->basehookcount;
288 L1->hook = L->hook;
289 resethookcount(L1);
290 /* initialize L1 extra space */
291 memcpy(lua_getextraspace(L1), lua_getextraspace(mainthread(g)),
292 LUA_EXTRASPACE);
293 luai_userstatethread(L, L1);
294 stack_init(L1, L); /* init stack */
295 lua_unlock(L);
296 return L1;
297}
298
299
300void luaE_freethread (lua_State *L, lua_State *L1) {

Callers 1

luaB_cocreateFunction · 0.70

Calls 3

luaC_newobjdtFunction · 0.70
preinit_threadFunction · 0.70
stack_initFunction · 0.70

Tested by

no test coverage detected