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

Function lua_newthread

xrepo/packages/l/lua/port/lua/src/lstate.c:286–314  ·  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;
288 lua_State *L1;
289 lua_lock(L);
290 g = G(L);
291 luaC_checkGC(L);
292 /* create new thread */
293 L1 = &cast(LX *, luaM_newobject(L, LUA_TTHREAD, sizeof(LX)))->l;
294 L1->marked = luaC_white(g);
295 L1->tt = LUA_VTHREAD;
296 /* link it on list 'allgc' */
297 L1->next = g->allgc;
298 g->allgc = obj2gco(L1);
299 /* anchor it on L stack */
300 setthvalue2s(L, L->top, L1);
301 api_incr_top(L);
302 preinit_thread(L1, g);
303 L1->hookmask = L->hookmask;
304 L1->basehookcount = L->basehookcount;
305 L1->hook = L->hook;
306 resethookcount(L1);
307 /* initialize L1 extra space */
308 memcpy(lua_getextraspace(L1), lua_getextraspace(g->mainthread),
309 LUA_EXTRASPACE);
310 luai_userstatethread(L, L1);
311 stack_init(L1, L); /* init stack */
312 lua_unlock(L);
313 return L1;
314}
315
316
317void luaE_freethread (lua_State *L, lua_State *L1) {

Callers 1

luaB_cocreateFunction · 0.70

Calls 5

preinit_threadFunction · 0.85
memcpyFunction · 0.85
lua_getextraspaceFunction · 0.85
stack_initFunction · 0.70
castFunction · 0.50

Tested by

no test coverage detected