lua-users home
lua-l archive

Re: Replacement for unlocked refs?

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


Hi,
> I just discovered that unlocked refs are no longer supported
> in the work3 release. I was using them to allow C++ objects to
> keep track of the table which represented them in Lua. What's
> the workaround to allow this in work3?
You can have, for instance, a locked reference to a table associating
your objects userdata with the corresponding object tables. Then set the
mode of this table to weak keys so that when your userdata is collected,
the whole pair is removed automatically from the table and associated
object table will also be collected.
Regards,
Diego.

AltStyle によって変換されたページ (->オリジナル) /