Guava EventBus dispatching

后端 未结 4 629
礼貌的吻别
礼貌的吻别 2021-02-07 16:35

I\'m using Guava\'s EventBus to kick off some processing and report results. Here\'s a very simple compilable example:

import com.google.common.eventbus.EventBu         


        
4条回答
  •  孤城傲影
    2021-02-07 17:05

    I try to summarize Guava's EventBus event delivery behaviour:

    If an event E1 is posted at moment t1, all subscribers are notified. If one of the subscribers posts an event itself in it's @Subscribe-method (a tiny moment later), the "new" event E2 is enqueued and delivered afterwards. Afterwards means here: after all @Subscribe-methods for E1 from t1 did return.

    Compare this kind of "cascaded" event posting to breadth first tree traversal.

    It seems to be the explicit choosen design of EventBus.

提交回复
热议问题