lua-users home
lua-l archive

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


Hello Brian,

Wednesday, April 28, 2004, 4:16:37 PM, you wrote:

HB> Lastly, the life span of a thread is dependent on the life
HB> span of its associated C++ object. So when a C++ object is
HB> destroyed, I want to invalidate any associated threads (i.e.
HB> status is dead) so that they will eventually be garbage collected.
HB> My preference is to do this through a C API call of some sort
HB> rather than resuming the thread with a special parameter that
HB> tells it to exits its main loop.

afaic thread cannot be collected until it is in the LUA stack. Find
your thread in the LUA stack and remove it, later this thread will be
collected :

for (int i=1, n=lua_gettop(L); i<=n; ++i)
    if ((lua_type(L,i) == LUA_TTHREAD) && (lua_tothread(L,i) == thread)) {
       lua_remove(L,i);
       break;
    }

btw, this procedure _must_ be done and in case your thread is over,
since if you don't do this LUA stack will overflow with time.

-- 
Best regards,
 Dmitriy                            mailto:iassenev@gsc-game.kiev.ua