lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


On 07/12/2011 17.52, Sam Roberts wrote:
You can't yield across a C call boundary. Not without luajit or coco.

This is allowed (and works):

-------------------------------------
static int
LuaWaitImageReady(lua_State *lua)
{
    int tid = luaL_checkint(lua, 1);
    bool waitFinished = (lua_toboolean(lua, 2) != 0);

    if (Gale->WaitImageReady(tid, waitFinished))
    {
        //ready: return normally
        return 0;
    }
    else
    {
        //not ready: suspend coroutine  ---  yield from C side ---
        return lua_yield(lua, 0);
    }
} //LuaWaitImageReady
-------------------------------------

The above function is called from a Lua coroutine.

--
  Enrico