MCPcopy Create free account
hub / github.com/DFHack/dfhack / lua_newthread

Function lua_newthread

depends/lua/src/lstate.c:255–282  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

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

Callers 2

NewCoroutineMethod · 0.85
luaB_cocreateFunction · 0.85

Calls 3

castFunction · 0.85
preinit_threadFunction · 0.85
stack_initFunction · 0.85

Tested by

no test coverage detected