This is an utility sub-class to Finalizable
which ensures that finalized_once
is called only once per instance. User classes implementing FinalizableOnce
shoud specialize finalize_once
and not finalize
. When manipulating the user
class, only finalize
should be called as it protects finalize_once
.
core :: FinalizableOnce :: defaultinit
core :: FinalizableOnce :: finalize_once
Real finalization method ofFinalizableOnce
, will be called only once
core :: FinalizableOnce :: finalized
Hasself
been finalized? (either by the GC or an explicit call to finalize
)
core :: FinalizableOnce :: finalized=
Hasself
been finalized? (either by the GC or an explicit call to finalize
)
core $ FinalizableOnce :: SELF
Type of this instance, automatically specialized in every classcore $ FinalizableOnce :: finalize
Liberate any resources held byself
before the memory holding self
is freed
core :: Object :: class_factory
Implementation used byget_class
to create the specific class.
core :: Finalizable :: defaultinit
core :: FinalizableOnce :: defaultinit
core :: Object :: defaultinit
core :: Finalizable :: finalize
Liberate any resources held byself
before the memory holding self
is freed
core :: FinalizableOnce :: finalize_once
Real finalization method ofFinalizableOnce
, will be called only once
core :: FinalizableOnce :: finalized
Hasself
been finalized? (either by the GC or an explicit call to finalize
)
core :: FinalizableOnce :: finalized=
Hasself
been finalized? (either by the GC or an explicit call to finalize
)
core :: Object :: is_same_instance
Return true ifself
and other
are the same instance (i.e. same identity).
core :: Object :: is_same_serialized
Isself
the same as other
in a serialization context?
core :: Object :: is_same_type
Return true ifself
and other
have the same dynamic type.
core :: Object :: output_class_name
Display class name on stdout (debug only).
# An object to be finalized only once
#
# This is an utility sub-class to `Finalizable` which ensures that `finalized_once`
# is called only once per instance. User classes implementing `FinalizableOnce`
# shoud specialize `finalize_once` and _not_ `finalize`. When manipulating the user
# class, only `finalize` should be called as it protects `finalize_once`.
class FinalizableOnce
super Finalizable
# Has `self` been finalized? (either by the GC or an explicit call to `finalize`)
var finalized = false
redef fun finalize
do
if finalized then return
finalize_once
finalized = true
end
# Real finalization method of `FinalizableOnce`, will be called only once
#
# See: `Finalizable::finalize` for restrictions on finalizer methods.
protected fun finalize_once do end
end
lib/core/gc.nit:40,1--64,3