lua-users home
lua-l archive

Re: [ANNOUNCE] LTN 6 - Weak references: implementation and use in Lua

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


Hi,
After some talk with John some weeks ago I made weakrefs part of
Sol. There's one additional thing I changed. Instead of calling
the GC method for NIL after garbage collection I added two call-
backs. _GC_PREACTION and _GC_POSTACTION. If these symbols are
defined in the global table they are executed before the garbage
collection starts and when it has finished. The pre-action hook
is nice to manage caches. I.e. cache this data for n gc-runs.
And the post-action hook as an replacement for the nil-gc-hook.
Why use these magic when a simple symbol is enough...
One thing I'm still thinking about is adding callbacks for gc'ed
refs itself. I.e. instead of the lock parameter give a function
to be called _after_ it has been collected. If no function is
given it's a locked reference. That way you don't have to check
all possible refs to find the ones that have been collected.
Just an idea at the moment. But I thing weak refs are a nice
method to act for collected tables and if they become used a lot
the scanning may become slow.
Ciao, ET.

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