lua-users home
lua-l archive

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


> Ok, but does it mean to leave Lua? If Lua is unlocked, then at that
> moment another
> OS thread could be scheduled, and this may try to execute using the same
> Lua state that was being used by another thread. Is this the desired
> behaviour?

Depends what you desire. The lock is about the Lua interpreter,
not about applications or libraries. When Lua calls C, it is in a
consistent state and, from its point of view, it can be called from any
thread without any problem. If you do not want that, you probably also
do not want other threads messing with "your" state before the first
call to lua_pcall (e..g, while you push the arguments to that call), and
there is no way the internal Lua lock can protect you from that.

Multithreading sucks.

-- Roberto