[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: A Question of Style
- From: Enrico Colombini <erix@...>
- Date: Wed, 07 Dec 2011 18:07:15 +0100
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