[Date Prev][Date Next][Thread Prev][Thread Next]
- Subject: Re: lua_yield
- From: "David Burgess" <dburgess@...>
- Date: Thu, 2 Nov 2006 12:51:30 +1100
Thank you Erik. This was the answer I wanted to hear.
On 11/2/06, Erik Cassel <email@example.com> wrote:
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
> 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
> In a Lua function
> int neverreturn (lua_State* L)
> return lua_yield(L,n);