Guava EventBus dispatching

后端 未结 4 1245
轻奢々
轻奢々 2021-02-07 16:30

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:20

    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.

提交回复
热议问题