[Date Prev][Date Next][Thread Prev][Thread Next]
- Subject: Re: the gc
- From: "D Burgess" <dburgess@...>
- Date: Sat, 12 Aug 2006 00:13:38 +1000
Sorry I was too brief.
All driven by C.
The lua code is initially loaded with luaL_loadbuffer() and
this chunk(function) is placed in a table.
A thread is created with lua_newthread and this thread
gets its own environment which metatables back to the
The function(chunk) is pushed into this thread and its
environment is set (with lua_setfenv() to the environment of
the thread into that it is pushed.
With the function on the top of the stack we then can
use lua_resume() to invoke the function.
The function environment which is the same as the thread
environment methinks is not shared between threads. Even
if I push the same function into the different thread stacks,
I am of the view that I get differnt functions with different
The original problem that I observed was that after the
lua_resume() completes, if you attempt to set the
environment of this function (which happens to still
be on thread stack()) then unlike the original setfenv()
which was constrained to the thread, this second
lua_setfenv() appears to set the environment of each of
the functions in each of the other threads (which are in
a yielded state) to nil.