diff options
author | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2022-11-01 17:14:01 -0300 |
---|---|---|
committer | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2022-11-01 17:14:01 -0300 |
commit | 9ede317c70ad82279f2e3962eb52904a17bf4b55 (patch) | |
tree | e2d60bac0e987fe2cb6da54222765a90414f3d2a /lstate.c | |
parent | ee645472ebe153e2c6669c84a632297a8110bdb6 (diff) | |
download | lua-9ede317c70ad82279f2e3962eb52904a17bf4b55.tar.gz lua-9ede317c70ad82279f2e3962eb52904a17bf4b55.tar.bz2 lua-9ede317c70ad82279f2e3962eb52904a17bf4b55.zip |
Threads are created like other objects
Using a version of 'luaC_newobj' that allows offsets (extra space
before the object itself).
Diffstat (limited to 'lstate.c')
-rw-r--r-- | lstate.c | 12 |
1 files changed, 4 insertions, 8 deletions
@@ -284,18 +284,14 @@ static void close_state (lua_State *L) { | |||
284 | 284 | ||
285 | 285 | ||
286 | LUA_API lua_State *lua_newthread (lua_State *L) { | 286 | LUA_API lua_State *lua_newthread (lua_State *L) { |
287 | global_State *g; | 287 | global_State *g = G(L); |
288 | GCObject *o; | ||
288 | lua_State *L1; | 289 | lua_State *L1; |
289 | lua_lock(L); | 290 | lua_lock(L); |
290 | g = G(L); | ||
291 | luaC_checkGC(L); | 291 | luaC_checkGC(L); |
292 | /* create new thread */ | 292 | /* create new thread */ |
293 | L1 = &cast(LX *, luaM_newobject(L, LUA_TTHREAD, sizeof(LX)))->l; | 293 | o = luaC_newobjdt(L, LUA_TTHREAD, sizeof(LX), offsetof(LX, l)); |
294 | L1->marked = luaC_white(g); | 294 | L1 = gco2th(o); |
295 | L1->tt = LUA_VTHREAD; | ||
296 | /* link it on list 'allgc' */ | ||
297 | L1->next = g->allgc; | ||
298 | g->allgc = obj2gco(L1); | ||
299 | /* anchor it on L stack */ | 295 | /* anchor it on L stack */ |
300 | setthvalue2s(L, L->top.p, L1); | 296 | setthvalue2s(L, L->top.p, L1); |
301 | api_incr_top(L); | 297 | api_incr_top(L); |