浏览代码

From Lua 5.3: Add lua_isyieldable().

Contributed by François Perrad.
Mike Pall 8 年之前
父节点
当前提交
f2e2a3f757
共有 2 个文件被更改,包括 8 次插入0 次删除
  1. 5 0
      src/lj_api.c
  2. 3 0
      src/lua.h

+ 5 - 0
src/lj_api.c

@@ -1113,6 +1113,11 @@ LUALIB_API int luaL_callmeta(lua_State *L, int idx, const char *field)
 
 /* -- Coroutine yield and resume ------------------------------------------ */
 
+LUA_API int lua_isyieldable(lua_State *L)
+{
+  return cframe_canyield(L->cframe);
+}
+
 LUA_API int lua_yield(lua_State *L, int nresults)
 {
   void *cf = L->cframe;

+ 3 - 0
src/lua.h

@@ -351,6 +351,9 @@ LUA_API int lua_loadx (lua_State *L, lua_Reader reader, void *dt,
 LUA_API const lua_Number *lua_version (lua_State *L);
 LUA_API void lua_copy (lua_State *L, int fromidx, int toidx);
 
+/* From Lua 5.3. */
+LUA_API int lua_isyieldable (lua_State *L);
+
 
 struct lua_Debug {
   int event;