| 286 | |
| 287 | |
| 288 | LUA_API lua_State *lua_newthread (lua_State *L) { |
| 289 | global_State *g = G(L); |
| 290 | GCObject *o; |
| 291 | lua_State *L1; |
| 292 | lua_lock(L); |
| 293 | luaC_checkGC(L); |
| 294 | /* create new thread */ |
| 295 | o = luaC_newobjdt(L, LUA_TTHREAD, sizeof(LX), offsetof(LX, l)); |
| 296 | L1 = gco2th(o); |
| 297 | /* anchor it on L stack */ |
| 298 | setthvalue2s(L, L->top.p, L1); |
| 299 | api_incr_top(L); |
| 300 | preinit_thread(L1, g); |
| 301 | L1->hookmask = L->hookmask; |
| 302 | L1->basehookcount = L->basehookcount; |
| 303 | L1->hook = L->hook; |
| 304 | resethookcount(L1); |
| 305 | /* initialize L1 extra space */ |
| 306 | memcpy(lua_getextraspace(L1), lua_getextraspace(g->mainthread), |
| 307 | LUA_EXTRASPACE); |
| 308 | luai_userstatethread(L, L1); |
| 309 | stack_init(L1, L); /* init stack */ |
| 310 | lua_unlock(L); |
| 311 | return L1; |
| 312 | } |
| 313 | |
| 314 | |
| 315 | void luaE_freethread (lua_State *L, lua_State *L1) { |
no test coverage detected