[Date Prev][Date Next][Thread Prev][Thread Next]
- Subject: Re: Lua threads share global data?
- From: John Klimek <jklimek@...>
- Date: Thu, 22 Dec 2005 16:17:47 -0500
Also, every time I create a thread (in Delphi using newThread =
lua_newthread(_luaVM)), the thread seems to remain on the stack even
after my lua_dofile() is finished.
So, after creating five or six threads I have ALL of them on top of
the stack in my main program. The manual says to use
lua_closethread() after calling lua_dofile() but lua_closethread()
Thanks for any help...
On 12/22/05, John Klimek <email@example.com> wrote:
> Thanks for the information!
> So... threads share the global environment with the parent lua_state.
> Therefore, if I change a global variable in my thread, it WILL also
> change in the parent lua_state.
> How can I prevent this and give my thread it's own global environment?
> The idea is so that each lua_state thread can have it's own individual
> global variable called "Connection" or whatever and each thread won't
> be overwritting each others data.
> On 12/21/05, Rici Lake <firstname.lastname@example.org> wrote:
> > On 21-Dec-05, at 8:46 PM, John Klimek wrote:
> > > Rici: Thanks for the link! It seems to talk a lot about "closures"
> > > but I'm not sure what they are. I've searched the Wiki and have seen
> > > some information but it was still a bit confusing... Can you explain
> > > this a little more to me?
> > Programming in Lua devotes a chapter to the subject:
> > <http://www.lua.org/pil/6.1.html>. But the short answer is that a
> > "closure" is the first-class Lua object which you probably think of as
> > a function.