lua-users home
lua-l archive

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


> I think we'll need Asko's help on this one, but from looking at Lanes 
> sources, I think that when you join a lane, the thread that called join 
> will be the one that calls the __gc methods. It seems that if the lane 
> gets collected while running, it will be marked as "self destruct". In 
> that case it seems that it will be the one in charge to call __gc handlers.

> Now that I think of it, it seems quite logical. If you join a lane, 
> you'll get its results back, so the lua_State in which it is running 
> can't be closed yet. If let the lane loose, it will be in charge of cleanup.

Yes that's right. I had a look at the code too and finally understood the "set_finalizer" part of the documentation. And this is exactly what I need.
So I simply added a desinit method to my module, a finalizer to my lane that calls it, some sanity check code in the desinit/gc implementation to avoid to perform desinits more than once or from the wrong thread, and all is fine now.

Problem solved :-)