greenrobot / EventBus

Event bus for Android and Java that simplifies communication between Activities, Fragments, Threads, Services, etc. Less code, better quality.
http://greenrobot.org/eventbus/
Apache License 2.0
24.68k stars 4.66k forks source link

Why use an ArrayList to store events instead of queue? #668

Open ice-coffee opened 3 years ago

ice-coffee commented 3 years ago

In source code, BackgroundPoster and HandlerPoster use PendingPostQueue to store events, but in EventBus use ArrayList to store events. Why not use the same queue as Handler?

snuweb commented 2 years ago

i think they are two different problems.

tomridder commented 1 year ago

In source code, BackgroundPoster and HandlerPoster use PendingPostQueue to store events, but in EventBus use ArrayList to store events. Why not use the same queue as Handler?

the reason of use arraylist is it only need to store the events , and traverse the eventTypes to get the event ,then give the event to subscriptionsByEventType ,finally get the subscriptionList.

he don't have to keep the order of first-in first-out.