[Date Prev][Date Next][Thread Prev][Thread Next]
- Subject: RE: scripts launching other scripts (coroutines)
- From: "Jerome Vuarand" <jerome.vuarand@...>
- Date: Wed, 13 Sep 2006 18:00:39 -0400
If you don't keep any reference to your thread in Lua storage space, the thread will be collected at next gc cycle. So if you keep a pointer to it in C and try to resume it later, it is probably the cause of your crash.
If you want to keep a reference to your thread in Lua storage space you can put it in the registry with the pointer as a key. It has been treated many times on the list already. Give us a snippet of your thread creation and destruction code so that someone can show you how to fix that issue.
De : email@example.com [mailto:firstname.lastname@example.org] De la part de Thomas Blom
Envoyé : 13 septembre 2006 16:15
À : email@example.com
Objet : Re: scripts launching other scripts (coroutines)
How is the thread known to be collectable? In my case there are no lua
references to the thread, which is created from the C call lua_newthread.
This call takes the "master" lua state which it inherits the global environment from. So is the thread not available for collection until this "master" lua state (which was obtained via lua_open, otherwise known as luaL_newstate).
Thanks for the response; I'm interested in the various archives, but presently crashing deep inside lua when calling resume on a new thread (after having stopped & started others a number of times as in my example), so any pointers appreciated.
> Thomas Blom wrote:
>> the Capi_killScript just deletes the C object - it doesn't free the
>> thread in any way (there is no way to free the thread created with
> Threads are subject to garbage collection and do not need to be
> manually freed.
>> But luaFn2 will never finish - is this OK?
> Yes. It's no problem if a coroutine is not dead (see
> coroutine.status) when it is collected.
Using Opera's revolutionary e-mail client: http://www.opera.com/mail/