[Date Prev][Date Next][Thread Prev][Thread Next]
- Subject: Re: abort a lua_newthread from C and re-use its lua_State?
- From: "Wesley Smith" <wesley.hoke@...>
- Date: Sat, 12 May 2007 09:49:50 -0700
Another suggestion is to keep a table with week keys in the coroutines
parent state and have userdata with a custom __gc as the values. When
the coroutines get collected, so will the userdata.
On 5/12/07, Shmuel Zeigerman <firstname.lastname@example.org> wrote:
Graham Wakefield wrote:
> This won't work. The registry is shared between the main state and all
> child states created within it.
You're right. I wrongly assumed that each coroutine had its
own registry. Thanks for pointing that out!
Then, Rici's advice is probably the best.
There is (at least) one more way to achieve that goal: create
a userdata with a __gc method and put it on the coroutine's
stack (say, as the 1-st parameter to the coroutine's main function).
(Tested today, and seems to work).