| 253 | |
| 254 | |
| 255 | LUA_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 | |
| 285 | void luaE_freethread (lua_State *L, lua_State *L1) { |
no test coverage detected