11 Object visiting
Visiting the containing objects of DGS nodes in the eviction queues
Consider the following xc++ code:
$class X isa ceda::IObject
{
$indep int x;
$dep int y;
$cache int z(int a) const { return a; }
};
This generates code in which independent or dependent DGS nodes are "embedded" in X - either directly as members (for $indeps, $deps and nullary $cache functions) or as the mapped value type of std::maps for non-nullary $cache functions.
For all these embedded independent/dependent DGS nodes the object instance X is called the containing object. This typically implements IObject.
The CSpace GC visits the DGSystem object which visits its eviction queues which in turn calls the virtual function
virtual void VisitContainingObject(IObjectVisitor& v) const = 0;
on every independent and dependent node in the eviction queue.
Since the eviction queue is just a linear list it is not necessary to trace the edges of the dependency graph to visit all DGS nodes.
The DGS nodes tend to be embedded in IObjects - i.e. the "containing object" implements IObject. The above virtual function should be implemented in order to visit the containing IObject.
VisitContainingObject is a bit of a misnomer because it is also used to visit $indep, $dep variables and also the mapped variables in $cache functions.
When a visit{...} block is specified on an $indep or $dep variable, an implementation of VisitContainingObject is generated which calls the provided code. WARNING: it doesn't perform the normal visiting of the containing object or the $indep or $dep variable.
Visiting the pointers to IObjects in the calculated values
Xcpp generates code to automatically visit the mapped values in $cache functions.
The visiting of the mapped values of cache functions can be disabled using <<--visit>>. For example:
$cache-^ <<-visit>> void Foo(X& x) const
{
CalculateX(x);
};
$dep^ <<-visit>> X x
invalidate { ... }
calc { ... };
visit {...} blocks on DGS nodes
In the xc++ language a visit handler can be defined on $indep and $dep variables and $cache functions. For example:
$mixin M
{
$dep- int y
visit { }
calc { y = foo(); };
};
Although supported these are not very useful anymore. E.g. CedaJigsaw doesn't use them at all!