diff options
author | Kaz Kylheku <kaz@kylheku.com> | 2020-12-31 06:53:02 -0800 |
---|---|---|
committer | Kaz Kylheku <kaz@kylheku.com> | 2020-12-31 06:53:02 -0800 |
commit | 7b508930b78766c14932847512824282aae59ec0 (patch) | |
tree | 123a3b75e0e1c36457b6f8381a78916a589f785c /txr.1 | |
parent | ee8addba7324e8bd66f107360051a6f200203dc5 (diff) | |
download | txr-7b508930b78766c14932847512824282aae59ec0.tar.gz txr-7b508930b78766c14932847512824282aae59ec0.tar.bz2 txr-7b508930b78766c14932847512824282aae59ec0.zip |
gc: add finalization count to objects.
With the finalization count, we don't have to scan the
freshobj array for duplicates when calling finalizers.
However, the limited range of the counter limits how many
times we can register a finalizer against an object.
* gc.c (make_obj): Reset the new fincount field to zero
for a newly minted object.
(call_finalizers_impl): Decrement the fincount for
each object. Only run the freshobj-related logic when
the count hits zero.
(gc_finalize): Bump the fincount of a registered object. If
the counter overflows, throw an exception.
* lib.h (obj_common): Add new field fincount for the
finalization count.
* tree.c (tr_rebuild): Fix up dummy object initializer
to accommodate the new member.
* txr.1: Document that there is a limit on the number
of times an object can be registered for finalization.
Diffstat (limited to 'txr.1')
-rw-r--r-- | txr.1 | 9 |
1 files changed, 7 insertions, 2 deletions
@@ -66770,8 +66770,13 @@ will be called with .meta object as its only argument. -Multiple finalizer functions can be registered for the same object. -They are all called when the object becomes unreachable. +Multiple finalizer functions can be registered for the same object, +up to an internal limit which is not required to be greater than 255. +If the limit is exceeded, +.code finalize +throws an error exception. + +All registered finalizers are called when the object becomes unreachable. Finalizers registered against an object may also be invoked and removed using the .code call-finalizers |