[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: lua_close() locks but never unlocks... ?
- From: Ben Sunshine-Hill <sneftel@...>
- Date: Thu, 2 Feb 2006 16:40:49 -0800
On 2/2/06, Chris <coderight@gmail.com> wrote:
> On 2/2/06, Luiz Henrique de Figueiredo <lhf@tecgraf.puc-rio.br> wrote:
> > Ok, but that does not mean you need need synchronization between the Lua
> states.
> > So, no need for lua_lock and friends.
> > --lhf
> >
>
> Hmm, in that case what is the point of having locking available at all?
If you are going to access the SAME Lua "universe" (created by
lua_open) from DIFFERENT threads, you'll need it.
> Consider Thread A is running some Lua code and it needs to update a value
> in Thread B which also running a Lua program. How does the value get from
> Thread A to Thread B without locking?
If they are different lua universes, it won't. They'll be different
lua universes, and values will not be shared. If they are the SAME lua
universe, as above, you use lua_lock.
I think you may be getting yourself confused between lua universes
(created with lua_open) and lua coroutines (created with
lua_newthread). To add to the confusion, coroutines are referred to
from the C side as a lua_State, even though they share internal
structures.
Ben