MCPcopy Create free account
hub / github.com/BigPig0/RelayLive / lua_newthread

Function lua_newthread

ThirdParty/lua/lua/lstate.c:253–280  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

251
252
253LUA_API lua_State *lua_newthread (lua_State *L) {
254 global_State *g = G(L);
255 lua_State *L1;
256 lua_lock(L);
257 luaC_checkGC(L);
258 /* create new thread */
259 L1 = &cast(LX *, luaM_newobject(L, LUA_TTHREAD, sizeof(LX)))->l;
260 L1->marked = luaC_white(g);
261 L1->tt = LUA_TTHREAD;
262 /* link it on list 'allgc' */
263 L1->next = g->allgc;
264 g->allgc = obj2gco(L1);
265 /* anchor it on L stack */
266 setthvalue(L, L->top, L1);
267 api_incr_top(L);
268 preinit_thread(L1, g);
269 L1->hookmask = L->hookmask;
270 L1->basehookcount = L->basehookcount;
271 L1->hook = L->hook;
272 resethookcount(L1);
273 /* initialize L1 extra space */
274 memcpy(lua_getextraspace(L1), lua_getextraspace(g->mainthread),
275 LUA_EXTRASPACE);
276 luai_userstatethread(L, L1);
277 stack_init(L1, L); /* init stack */
278 lua_unlock(L);
279 return L1;
280}
281
282
283void luaE_freethread (lua_State *L, lua_State *L1) {

Callers 1

luaB_cocreateFunction · 0.85

Calls 3

preinit_threadFunction · 0.85
stack_initFunction · 0.70
GFunction · 0.50

Tested by

no test coverage detected