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