diff options
| author | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2002-10-25 17:05:28 -0300 |
|---|---|---|
| committer | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2002-10-25 17:05:28 -0300 |
| commit | 96e15b8501e5d8fc40c475cbac573f910ab5853b (patch) | |
| tree | 2c8efededa6849704f0db3075d0cbe0efaa40b2d /ldo.c | |
| parent | 0fd91b1b087b478fffa36f96bc0f608d86627a4b (diff) | |
| download | lua-96e15b8501e5d8fc40c475cbac573f910ab5853b.tar.gz lua-96e15b8501e5d8fc40c475cbac573f910ab5853b.tar.bz2 lua-96e15b8501e5d8fc40c475cbac573f910ab5853b.zip | |
threads now are real Lua objects, subject to garbage collection
Diffstat (limited to 'ldo.c')
| -rw-r--r-- | ldo.c | 26 |
1 files changed, 16 insertions, 10 deletions
| @@ -1,5 +1,5 @@ | |||
| 1 | /* | 1 | /* |
| 2 | ** $Id: ldo.c,v 1.195 2002/10/08 18:46:08 roberto Exp roberto $ | 2 | ** $Id: ldo.c,v 1.196 2002/10/09 13:42:01 roberto Exp roberto $ |
| 3 | ** Stack and Call structure of Lua | 3 | ** Stack and Call structure of Lua |
| 4 | ** See Copyright Notice in lua.h | 4 | ** See Copyright Notice in lua.h |
| 5 | */ | 5 | */ |
| @@ -343,16 +343,22 @@ LUA_API int lua_resume (lua_State *L, lua_State *co) { | |||
| 343 | int status; | 343 | int status; |
| 344 | lua_lock(L); | 344 | lua_lock(L); |
| 345 | ci = co->ci; | 345 | ci = co->ci; |
| 346 | if (ci == co->base_ci) /* no activation record? ?? */ | 346 | if (ci == co->base_ci) { /* no activation record? ?? */ |
| 347 | luaG_runerror(L, "cannot resume dead thread"); | 347 | luaO_pushfstring(L, "cannot resume dead thread"); |
| 348 | if (co->errorJmp != NULL) /* ?? */ | 348 | status = LUA_ERRRUN; |
| 349 | luaG_runerror(L, "cannot resume active thread"); | 349 | } |
| 350 | status = luaD_rawrunprotected(co, resume, &numres); | 350 | else if (co->errorJmp != NULL) { /* ?? */ |
| 351 | if (status == 0) | 351 | luaO_pushfstring(L, "cannot resume active thread"); |
| 352 | move_results(L, co->top - numres, co->top); | 352 | status = LUA_ERRRUN; |
| 353 | } | ||
| 353 | else { | 354 | else { |
| 354 | setobj(L->top++, co->top - 1); /* move error message to other stack */ | 355 | status = luaD_rawrunprotected(co, resume, &numres); |
| 355 | co->ci = co->base_ci; /* `kill' thread */ | 356 | if (status == 0) |
| 357 | move_results(L, co->top - numres, co->top); | ||
| 358 | else { | ||
| 359 | setobj(L->top++, co->top - 1); /* move error message to other stack */ | ||
| 360 | co->ci = co->base_ci; /* `kill' thread */ | ||
| 361 | } | ||
| 356 | } | 362 | } |
| 357 | lua_unlock(L); | 363 | lua_unlock(L); |
| 358 | return status; | 364 | return status; |
