| 271 | |
| 272 | |
| 273 | LUA_API lua_State *lua_newthread (lua_State *L) { |
| 274 | global_State *g = G(L); |
| 275 | GCObject *o; |
| 276 | lua_State *L1; |
| 277 | lua_lock(L); |
| 278 | luaC_checkGC(L); |
| 279 | /* create new thread */ |
| 280 | o = luaC_newobjdt(L, LUA_TTHREAD, sizeof(LX), offsetof(LX, l)); |
| 281 | L1 = gco2th(o); |
| 282 | /* anchor it on L stack */ |
| 283 | setthvalue2s(L, L->top.p, L1); |
| 284 | api_incr_top(L); |
| 285 | preinit_thread(L1, g); |
| 286 | L1->hookmask = L->hookmask; |
| 287 | L1->basehookcount = L->basehookcount; |
| 288 | L1->hook = L->hook; |
| 289 | resethookcount(L1); |
| 290 | /* initialize L1 extra space */ |
| 291 | memcpy(lua_getextraspace(L1), lua_getextraspace(mainthread(g)), |
| 292 | LUA_EXTRASPACE); |
| 293 | luai_userstatethread(L, L1); |
| 294 | stack_init(L1, L); /* init stack */ |
| 295 | lua_unlock(L); |
| 296 | return L1; |
| 297 | } |
| 298 | |
| 299 | |
| 300 | void luaE_freethread (lua_State *L, lua_State *L1) { |
no test coverage detected