On Fri, Mar 25, 2011 at 7:26 AM, <[email protected]> wrote:

> I have a simple question on one of the test. As I was making this
> correction I noticed that one of my test case comment is wrong.
>
> The last remove test is actually incorrect (my comment). My question is
> what is the expected output of the last test. If you have 2 nested event
> bus, and if you call removeHandlers on the inner eventbus. Do you expect
> this remove to propagate to the outer event bus and remove it from its
> registration?


I really hadn't thought about nesting the things before your patch came in.
You'll note that there is no support for nesting among activities in
general.

With the current setup, the semantics seem okay. Am I reading it right?

   - I nest innerBus in outerBus
   - I register innerHandler and outerHandler on them, respectively
   - If I call innerBus.removeHandlers(), innerHandler will no longer
   receive events
   - If I instead call outerBus.removeHandlers(), neither handler will
   receive events any longer

The only problem is that the HandlerRegistrations vended by InnerResettable
cannot be gc'd until removeHandlers is called on both InnerResettable and
OuterResettable.

If that's the case, I think this implementation is fine, if we javadoc
carefully. I think your test shouldn't be about the specific intermediate
count on outerBus, but rather focus that both busses get to zero when their
removes are called.

Am I answering the right question?

rjrjr


> If the answer is no it shouldn't propagate to the upper eventbus. The
> current setup will work nicely. The only weird thing is that the upper
> Resettable event bus thinks the event is still attached.
>
> If the answer is yes and the eventbus should be removed from the top. I
> came up with few ways to deal with the situation with pros and cons.
> 1. Recognize that you are wrapping a resettable event bus and don't
> record the registrationHandler at this level (simple pass through). On
> removeHandlers call removeHandhlers on the wrapped bus.
> * Pros: No new memory leak introduced.
> * Cons: If other wrapper is used this method will not work correctly.
> For example ResettableEventBus ->CountingEventBus -> ResettableEventBus
> -> SimpleEventBus.
>
> 2. Create a event that fires when things are removed from simple event
> bus (RemoveEvent of some sort).
> * Pros: Will work regardless of how complicated the nesting gets.
> * Cons: How do we know when to unregister our ResettableEventBus from
> this event? Simple solution is to unregister when nothing is left in the
> registration and add it back when something gets attached. Also more
> complex. Should user be allowed to attach to this event?
>
> Number 2 is definitely the best solution but rises many questions...
>
> Comment/Suggestion?
>
>
> http://gwt-code-reviews.appspot.com/1388804/
>
>

-- 
http://groups.google.com/group/Google-Web-Toolkit-Contributors

Reply via email to