[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: lua_close() locks but never unlocks... ?
- From: Mark Hamburg <mhamburg@...>
- Date: Thu, 02 Feb 2006 16:40:23 -0800
If you can run independent universes and use a model in which you message
between them, then you could adopt a solution like the one we have. We have
a "transit universe" which has a lock around it. Other universes wanting to
put data into or take it out of the transit universe have to acquire the
transit universe lock while they do so but the rest of the time, they can
run lock free.
lua_lock/lua_unlock is for use when you have multiple threads accessing a
single universe. In that case, you generally wouldn't be calling lua_close
since that signals that all work with that universe is done.
Mark
on 2/2/06 4:32 PM, Chris at 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?
>
> 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? They are both actively running code. As far
> as I know the only possible way would be for Thread B to be polling for
> changes or something (which is not what you want in a multithreaded
> application).
>
> Maybe the locking in Lua works completely different from what I am thinking, I
> don't know. It doesn't seem very thread friendly.