lua-users home
lua-l archive

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


On 2/2/06, Chris <coderight@gmail.com> wrote:
> On 2/2/06, Ben Sunshine-Hill <sneftel@gmail.com> wrote:
> > 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.
> >
>
>  That doesn't make sense to me.  Different universes accessing each other is
> the same thing as as the same universe from different threads.  They are
> both native threads, doesn't matter if they are Lua universes or not.

But different universes cannot access each other. At least, not
without invoking C functions. Those C functions are just like any
other C functions: they need to lock data which is shared between
threads.

Ben