lua-users home
lua-l archive

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


On Tue, 25 Sep 2001, Joshua Jensen wrote:

> So if I have a callback:
>
> static int MyCallback(lua_State* L)
> {
>     lua_pushnumber(L, 5.0);
>     lua_pushstring(L, "fdsa");
>
>     return 2;
> }
>
> Is normal usage of lua_push*() enough, since internally,
> lua_pushnumber() and lua_pushstring() call lua_lock()/lua_unlock()?  Or
> do I have to wrap it like?

Lua 4.0 was quite sensitive about things you could do in a GC callback. But
we tried to correct that in Lua 4.1. You should be able to do whatever you
want in a GC callback (even to invoke the garbage collector again). The
only restriction is that you cannot raise errors. And yes, both pushnumber
and pushstring use the lock, you should never need to use lua_lock/unlock
outside Lua (they are not even exported).

-- Roberto