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

Function lua_newthread

third-party/lua-5.4.6/src/lstate.c:288–312  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

286
287
288LUA_API lua_State *lua_newthread (lua_State *L) {
289 global_State *g = G(L);
290 GCObject *o;
291 lua_State *L1;
292 lua_lock(L);
293 luaC_checkGC(L);
294 /* create new thread */
295 o = luaC_newobjdt(L, LUA_TTHREAD, sizeof(LX), offsetof(LX, l));
296 L1 = gco2th(o);
297 /* anchor it on L stack */
298 setthvalue2s(L, L->top.p, L1);
299 api_incr_top(L);
300 preinit_thread(L1, g);
301 L1->hookmask = L->hookmask;
302 L1->basehookcount = L->basehookcount;
303 L1->hook = L->hook;
304 resethookcount(L1);
305 /* initialize L1 extra space */
306 memcpy(lua_getextraspace(L1), lua_getextraspace(g->mainthread),
307 LUA_EXTRASPACE);
308 luai_userstatethread(L, L1);
309 stack_init(L1, L); /* init stack */
310 lua_unlock(L);
311 return L1;
312}
313
314
315void 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