deleted - returns whether an object has been marked for deletion
oadl::deleted(obj)
During garbage collection, objects that are not reachable will be
deleted. If an object to be deleted has a
destroy() method, the object will be made into a
zombie, and its destroy() method will be
called at a non-deterministic time during garbage collection. The
oadl::deleted() intrinsic procedure can be used
to determine whether an object is in that zombie state.
true if obj is a zombie,
false otherwise
TypeCheck if obj is not an
Object
z = nil
resurrect = true
class foo {
public var a, b;
public proc create(x) {
a = @x; // a will be a non-constant
b = x; // b may be constant if x is constant
"foo.create - returning ", self, '\n';
}
public proc destroy() {
"", self, ".destroy() {\n";
" self.readonly() = ", self.readonly(), '\n';
" oadl::deleted(self) = ", oadl::deleted(self), '\n';
" dynamic copy ", a, " vs static ref ", b, '\n';
"}\n";
if (resurrect) z = self;
}
}
a = new foo("foo")
foo.create - returning #OBJ(1)
a = nil
oadl::gc()
#OBJ(1).destroy() {
self.readonly = true
oadl::deleted(self) = true
dynamic copy nil vs static ref foo
}
// Set z.b to a dynamic copy of the string - it will get deleted
// next time around
z.b = @z.b
// Examinine resurrected zombie z
"z = ", z, "; z.b = ", z.b, '\n'
z = #OBJ(1); z.b = foo
"oadl::deleted(z) = ", oadl::deleted(z), '\n'
oadl::deleted(z) = false
resurrect = false
z = nil
oadl::gc()
#OBJ(1).destroy() {
self.readonly = true
oadl::deleted(self) = true
dynamic copy nil vs static ref nil
}