MCPcopy Create free account
hub / github.com/Serial-Studio/Serial-Studio / lua_newthread

Function lua_newthread

lib/lua/src/lstate.c:286–310  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

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

Callers 1

luaB_cocreateFunction · 0.85

Calls 4

luaC_newobjdtFunction · 0.85
preinit_threadFunction · 0.85
stack_initFunction · 0.85
GFunction · 0.50

Tested by

no test coverage detected