lua-users home
lua-l archive

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

And questions for Wim,
Can you further explain the weak keyed table?

A fiber is a pair (userdata, lua thread). The lua thread part is private to the userdata. To prevent the lua threads from early gc, I maintain a weak keyed mapping { userdata --> lua thread }. As soon as the fiber dies I remove the userdata to allow gc of the thread. Of course when the userdata is gc'ed there is obviously no need to remove it from this mapping explicitly.

I think it would be a good idea to add a __gc to something that
will execute ConvertFiberToThread() when lua_close() is called.

Maybe, but (as already mentioned in the CoCo thread) this is a fairly new API call and it is certainly not available on my Win 98 based machine!

Also the documentation of CreateFiber is a bit worrying since it mentions some FP state problem. CreateFiberEx should fix that, but is only available since some W2K version.