On Tue, Aug 26, 2014 at 12:17 PM, Nick Wellnhofer <[email protected]> wrote:
> If we keep a list of all Clownfish objects passed to the host language, we
> could implement a “mark” function that runs through that list and marks all
> objects still referenced from C space. Then the host finalizer would only
> fire when there are no references from either host or C space and the object
> can be destroyed.
Haha, this is backwards from how I would have conceived it -- I figured we'd
keep a list of host objects only referenced from C-space.
I think this means we have to differentiate between these two situations:
* refcount falls to 0 but host wrapper is still live so don't invoke
Destroy.
* refcount falls to 0 and no host wrapper exists so invoke Destroy.
> What we definitely want to avoid is forcing Clownfish classes to implement
> their own mark method.
A "visit" function which defaults to visiting instance variables which descend
from Obj* could be reused for both "mark" and "destroy". It could take a
function pointer which either DECREFs or marks before following non-NULL refs.
Classes like Hash and VArray would need custom implementations.
>> BTW, it occurs to me that instead of requiring Perl users to use inside-out
>> fields, we could enable hashref overloading one every Clownfish
>> object similar to how we have it on Lucy::Document::Doc.
>
> That would be nice.
https://issues.apache.org/jira/browse/CLOWNFISH-1
Marvin Humphrey