| 5561 | |
| 5562 | |
| 5563 | LUA_API int lua_resume (lua_State *L, int nargs) { |
| 5564 | int status; |
| 5565 | lua_lock(L); |
| 5566 | if (L->status != LUA_YIELD && (L->status != 0 || L->ci != L->base_ci)) |
| 5567 | return resume_error(L, "cannot resume non-suspended coroutine"); |
| 5568 | if (L->nCcalls >= LUAI_MAXCCALLS) |
| 5569 | return resume_error(L, "C stack overflow"); |
| 5570 | luai_userstateresume(L, nargs); |
| 5571 | lua_assert(L->errfunc == 0); |
| 5572 | L->baseCcalls = ++L->nCcalls; |
| 5573 | status = luaD_rawrunprotected(L, resume, L->top - nargs); |
| 5574 | if (status != 0) { /* error? */ |
| 5575 | L->status = cast_byte(status); /* mark thread as `dead' */ |
| 5576 | luaD_seterrorobj(L, status, L->top); |
| 5577 | L->ci->top = L->top; |
| 5578 | } |
| 5579 | else { |
| 5580 | lua_assert(L->nCcalls == L->baseCcalls); |
| 5581 | status = L->status; |
| 5582 | } |
| 5583 | --L->nCcalls; |
| 5584 | lua_unlock(L); |
| 5585 | return status; |
| 5586 | } |
| 5587 | |
| 5588 | |
| 5589 | LUA_API int lua_yield (lua_State *L, int nresults) { |
no test coverage detected