new function 'lua_isyieldable' (and 'coroutine.isyieldable')

This commit is contained in:
Roberto Ierusalimschy
2014-05-08 10:52:20 -03:00
parent ef83457427
commit 1bd70a8e40
3 changed files with 26 additions and 7 deletions

7
ldo.c
View File

@@ -1,5 +1,5 @@
/*
** $Id: ldo.c,v 2.114 2014/02/26 15:27:56 roberto Exp roberto $
** $Id: ldo.c,v 2.115 2014/03/21 13:52:33 roberto Exp roberto $
** Stack and Call structure of Lua
** See Copyright Notice in lua.h
*/
@@ -571,6 +571,11 @@ LUA_API int lua_resume (lua_State *L, lua_State *from, int nargs) {
}
LUA_API int lua_isyieldable (lua_State *L) {
return (L->nny == 0);
}
LUA_API int lua_yieldk (lua_State *L, int nresults, int ctx, lua_CFunction k) {
CallInfo *ci = L->ci;
luai_userstateyield(L, nresults);