| 283 | |
| 284 | |
| 285 | LUA_API lua_State *lua_newthread (lua_State *L) { |
| 286 | global_State *g; |
| 287 | lua_State *L1; |
| 288 | lua_lock(L); |
| 289 | g = G(L); |
| 290 | luaC_checkGC(L); |
| 291 | /* create new thread */ |
| 292 | L1 = &cast(LX *, luaM_newobject(L, LUA_TTHREAD, sizeof(LX)))->l; |
| 293 | L1->marked = luaC_white(g); |
| 294 | L1->tt = LUA_VTHREAD; |
| 295 | /* link it on list 'allgc' */ |
| 296 | L1->next = g->allgc; |
| 297 | g->allgc = obj2gco(L1); |
| 298 | /* anchor it on L stack */ |
| 299 | setthvalue2s(L, L->top, L1); |
| 300 | api_incr_top(L); |
| 301 | preinit_thread(L1, g); |
| 302 | L1->hookmask = L->hookmask; |
| 303 | L1->basehookcount = L->basehookcount; |
| 304 | L1->hook = L->hook; |
| 305 | resethookcount(L1); |
| 306 | /* initialize L1 extra space */ |
| 307 | memcpy(lua_getextraspace(L1), lua_getextraspace(g->mainthread), |
| 308 | LUA_EXTRASPACE); |
| 309 | luai_userstatethread(L, L1); |
| 310 | stack_init(L1, L); /* init stack */ |
| 311 | lua_unlock(L); |
| 312 | return L1; |
| 313 | } |
| 314 | |
| 315 | |
| 316 | void luaE_freethread (lua_State *L, lua_State *L1) { |
no test coverage detected