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

when postingState.isPosting is equals true? #359

Open Hikyu opened 8 years ago

Hikyu commented 8 years ago

Hello,I want to know that postingState.isPosting in EventBus.post method whether may be true? I think that the eventQueue's size will no larger than 1 for ever.

greenrobot-team commented 8 years ago

The variable in question is set to true inside of the post(Object) method.

This should probably protect against a thread posting another event until the first one was sent out. Though as you, I am not sure how this can happen within the same thread (though I am not familiar with the pitfalls of ThreadLocal).

@greenrobot Any insight on why this condition exists (file history is gone, so can not look up that way)? -ut