Weak event listener

Mark S. Miller erights at google.com
Wed Apr 3 14:05:11 PDT 2013


On Wed, Apr 3, 2013 at 1:10 PM, David Bruant <bruant.d at gmail.com> wrote:

>  Le 03/04/2013 21:18, Mark S. Miller a écrit :
>
>
>   Do languages which added WeakRefs have a form of revokable reference
>> too? What difference would it make?
>>
>
>  E has both. In practice, my sense is that their use cases are disjoint,
> and that both are needed.
>
> Do you have examples of use? May be links to E code.
>
> In what way is the GC-notification mechanism really necessary? (that's the
> part that I'm personally annoyed with most).
> I would be much less bothered if weakrefs were in essence revocable
> references for which only the GC has the revoke function (called on GC of
> the underlying target).
> It seems it would already solve the use cases exposed on the list which
> (my summary) Kevin expressed as "A core part of the problem here is that
> the distinction between an 'important' reference - one that must keep an
> object alive - and an 'incidental' reference, that only need exist as long
> as it target does"
>
> Whatever final form is chosen (and even if weakrefs are only for ES7),
> would it make sense to unify what a revoked proxy and a dead weakref look
> like?
> Both look very close in what they are.
>

The main use of weakrefs in E is indeed related to proxies, but not in the
way you may expect. Weakrefs are used to implement CapTP's distributed
acyclic garbage collector. An E remote-reference-proxy is used as the local
representative of a remote object. Though such E proxies are more like
Q/ES7 promises than like ES6 proxies. A weakref is used to determine when
there is no longer any local need for a reference to that remote object.
When this is detected, the local vat sends a message (GCExportOp and
GCAnswerOP at <http://erights.org/elib/distrib/captp/DeliverOp.html#step9>)
to the remote vat so the remote vat can clean up its corresponding incoming
tables.

A captp-like protocol for distributed Q should make use of the same
technique, but won't be able to until we add weakrefs to ES7. Until then, Q
will leak a tremendous amount of distributed acyclic cross-vat garbage.




>
>
> David
>



-- 
    Cheers,
    --MarkM
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.mozilla.org/pipermail/es-discuss/attachments/20130403/a1ffb128/attachment.html>


More information about the es-discuss mailing list