[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: Co-Routines not dying and resulting in a crash (stack overflow?)
- From: "Raymond Jacobs" <raymondj@...>
- Date: Wed, 12 Apr 2006 14:43:17 -0400
Ah,
lua_ref and lua_unref allow you to keep an object in C so it doesn't get GC'd,
I was looking for somthing like that but couldn't find it, that sounds like a great plan.
thanks again Eric =)
-Raymond
On 4/12/06, Eric Scouten <scouten@adobe.com> wrote:
On 12 Apr 2006, at 11:07, Raymond Jacobs wrote:
> Hi Eric,
>
> Thanks for the reply, I am currently solving it by iterating the
> stack and removing the co-routine when i have decided it is dead,
> this work but it's a little 'ick', my main issues were that I
> didint know (and the documentation did not specify) that the co-
> routines do not die upon completion.
>
> it seems the optimal situation would be to increase the reference
> count of the new thread when i create it, and immediately pop it
> off the stack (since when i need to get it later the position is
> not predictable and i need to search) and then later be able to
> decrement the ref count by simply having the lua_State* that
> represents the co-routine.
>
> any thoughts on that?
Not sure I follow what you mean by "increase the reference count."
Lua does not use reference counting anywhere; it's exclusively
garbage collected.
In our application, we approach this problem by storing a reference
to the new thread in the global reference list and removing that
reference when the coroutine is done. I think that's done via lua_ref
and lua_unref, but I don't have the code handy at the moment.
-Eric