lua-users home
lua-l archive

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


I use this pattern a lot in a slightly different context.  When a thread
wants to "wait" for an event in C++ to trigger it goes to sleep. If the
source of the event is deleted, then the waiting thread is effectively
terminated, because the source releases its reference to the yielding
thread.  Likewise, if the C++ object that started the thread is deleted, I
disconnect all events, which causes the sleeping thread (and its children)
to be collected.

I don't get any "attempt to yield across metamethod/C-call boundary" errors.

I've watched the GC and it does collect the "dead" yielding threads
eventually.

-Erik


> If Ilua_yield from the C code, and then remove in references to the 
> thread, will it collect OK?
> 
> That is, I was thinking of using lua_yield as a means of script
> termination.
> 
> In a Lua function
> 
> int neverreturn (lua_State* L)
> {
>   ...
>  return lua_yield(L,n);
> }
> 
> db