lua-users home
lua-l archive

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


This is working; but I wonder - will the coroutine become invalidated as it is collected, before the __gc of the userdata is called?

On May 12, 2007, at 9:49 AM, Wesley Smith wrote:

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.

wes

On 5/12/07, Shmuel Zeigerman <shmuz@actcom.co.il> 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).

--
Shmuel


grrr waaa
www.grahamwakefield.net