MCPcopy Create free account
hub / github.com/ObEngine/ObEngine / lua_newthread

Function lua_newthread

extlibs/lua/src/lstate.c:313–341  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

311
312
313LUA_API lua_State *lua_newthread (lua_State *L) {
314 global_State *g = G(L);
315 lua_State *L1;
316 lua_lock(L);
317 luaC_checkGC(L);
318 /* create new thread */
319 L1 = &cast(LX *, luaM_newobject(L, LUA_TTHREAD, sizeof(LX)))->l;
320 L1->marked = luaC_white(g);
321 L1->tt = LUA_VTHREAD;
322 /* link it on list 'allgc' */
323 L1->next = g->allgc;
324 g->allgc = obj2gco(L1);
325 /* anchor it on L stack */
326 setthvalue2s(L, L->top, L1);
327 api_incr_top(L);
328 preinit_thread(L1, g);
329 L1->nCcalls = getCcalls(L);
330 L1->hookmask = L->hookmask;
331 L1->basehookcount = L->basehookcount;
332 L1->hook = L->hook;
333 resethookcount(L1);
334 /* initialize L1 extra space */
335 memcpy(lua_getextraspace(L1), lua_getextraspace(g->mainthread),
336 LUA_EXTRASPACE);
337 luai_userstatethread(L, L1);
338 stack_init(L1, L); /* init stack */
339 lua_unlock(L);
340 return L1;
341}
342
343
344void luaE_freethread (lua_State *L, lua_State *L1) {

Callers 2

luaB_cocreateFunction · 0.85
createMethod · 0.85

Calls 2

preinit_threadFunction · 0.85
stack_initFunction · 0.85

Tested by

no test coverage detected