lua-users home
lua-l archive

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


----- Original Message ----- 
From: "Luiz Henrique de Figueiredo" <lhf@tecgraf.puc-rio.br>
To: <lua@bazar2.conectiva.com.br>
Sent: Friday, May 30, 2003 1:03 PM
Subject: Re: Using a lua state in different threads


> >Is it save to access a lua state from different native threads?
>
> No.
>
> >If not is there an (easy?) way to allow multithreading for lua states?
>
> Yes, it's just a matter of defining a couple of macros and recompiling.
> See http://www.tecgraf.puc-rio.br/~diego/luathreads/
> --lhf
>


I looked into the lua and luathreads source and it seems it is enough to
redefine the "lua_lock(L)" and "lua_unlock(L)" macros, since I can have all
necessary data as globals in my program (I only have 2 threads and 1 lua
state).

However, it seems, as long as the thread with the lua program runs, my other
thread cannot access the lua state, since lua_pcall(...) locks the state at
its entry. So I wonder how I actually can modify a lua state from the other
thread while the lua program is running. Is this possible at all?

Thanks for any help