What is the status of Weak References?

Marius Gundersen gundersen at gmail.com
Sat Mar 2 12:13:07 PST 2013


> I won't say it's absolutely better than WeakRefs and it may not apply to
the data binding case (?), but it's an interesting pattern to keep in mind.

I can't see how this would work in an observer/listener application. The
listening object has no way of knowing if it will be deleted when the event
occurs, so it cannot decide whether to resubscribe or not. If all
references to it were still deleted, it would not go away. It would
therefore need a shouldNotResubscribe flag, which must be set when it
should be deleted. When the next event occurs it can react and decide not
to resubscribe. This means that a listening object still needs a dispose
method (to set the shouldNotResubscribe flag), and it also means that it
would not be deleted until the next event occurs, which could be in a very
long time.

Marius


On Sat, Mar 2, 2013 at 7:53 PM, Bill Frantz <frantz at pwpconsult.com> wrote:

> On 3/2/13 at 3:47 AM, bruant.d at gmail.com (David Bruant) wrote:
>
>  "I won't say it's absolutely better than WeakRefs and it may not apply to
>> the data binding case (?), but it's an interesting pattern to keep in mind."
>>
>
> Speaking from ignorance here.
>
> One advantage of the "resubscribe for every event" pattern is that if the
> events are generated in one process -- an animation process is the example
> used here -- and a message is sent to the observer in another process, and
> the observer is slow, the natural outcome will be to drop frames instead of
> queue up a lot of messages pertaining to events that no longer need to be
> processed.
>
> Cheers - Bill
>
> ------------------------------**------------------------------**
> -------------
> Bill Frantz        | When it comes to the world     | Periwinkle
> (408)356-8506      | around us, is there any choice | 16345 Englewood Ave
> www.pwpconsult.com | but to explore? - Lisa Randall | Los Gatos, CA 95032
>
>
> ______________________________**_________________
> es-discuss mailing list
> es-discuss at mozilla.org
> https://mail.mozilla.org/**listinfo/es-discuss<https://mail.mozilla.org/listinfo/es-discuss>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.mozilla.org/pipermail/es-discuss/attachments/20130302/cc468301/attachment.html>


More information about the es-discuss mailing list