This file was automatically generated from http://svn.pugscode.org/pugs/docs/notes/GC.pod on Wed Jun 6 22:16:47 2007 GMT, revision 16639.
GC - The interface to the runtime Garbage collector.
class Philosopher is GC::timely {
has Fork::Lock $.lfork;
has Fork::Lock $.rfork;
method dine {
$.lfork.grab;
$.rfork.grab;
...
}
method DESTORY {
$.rfork.release;
$.lfork.release;
}
}
my $long_lived_configuration_verbal_that_dosnt_need_much_checking is GC::tardy;
my @pantheon of God is GC::immortal;
sub draw ($display,@frames) { no GC::delay; # Slowing down to check garbage would upset our little # animation. for @frames -> {$display.show($_)} }
# These are all defined in terms of "objects", the GC doesn't just # work on objects, it should be cell or container I think.
The GC API supplies the following adjectives.
Prevents collection of this object even when it has passed out of visibility.
# Is this even a good idea? It may be usefull for FFI. Though it's # clearly a heavy wizardy type of thing. If nobody thinks it may be # useful I think this dangerous beast can be removed even before it # sees the light of day.
Indicates to the GC the objects that this object has references to are only referenced by this object. Hence if this object is no longer visible then all of the objects that this object refers to are also no longer visible.
GCs may use this infomation for optimization. The behavour of the GC when encountering an object that is marked keystone but does not have the keystone property is unspecified, and likely to be inconsistent.
The Adjectives can be used meaningfully in the following ways.
my $item is GC::timely;
Whatever is stored within the scalar verable requires timely collection.
my @array is GC::timely;
Each member of the @array requires timely collection.
"A string" is GC::timely; # Or should this be but CG:timely ?
{a => "hash"} is GC::timely; # corrections/confirmation please.
The string/hash requires timely collection.
class Philosopher is GC::timely {...}
The Philosopher object requires timely collection.
sub ($x) is GC::timely {...}
The closure created by this sub requires timely collection.
use GC::timely;
All objects are treated as timely while this is the current scope.
Requests that the GC not do any finalization while the program is within this lexical scope. Note the GC may detect and queue objects for finalization, it's just not permitted to carry out finalization.
GC::delay and GC::destroy are orthogonal, setting them both to no effectively disables the Garbage collector.
Requests that GCs with delay run at this time. For example a this will trigger a mark and sweep style GCs mark and sweep operation. GC::delay will cause a delay even in blocks marked no GC::delay. The meaning of the $depth is for the most part implementation specific, with the following limitations.
GC::delay may return the number of bytes freed.
Forcefully finalize $object, even if object is still in scope. If recursive is true then the GC will forcefully finalize everything that $object points to.