Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Don't use dispatcher thread #151

Open
techyourchance opened this issue Jun 21, 2017 · 3 comments
Open

Don't use dispatcher thread #151

techyourchance opened this issue Jun 21, 2017 · 3 comments
Assignees

Comments

@techyourchance
Copy link

Hi,
First of all thanks for this great project.

I'd like to configure MBassador such that the messages are being dispatched by the thread that publishes them, but processed by background threads supplied by AsynchronousHandlerInvocation.

I thought that this could work:

    private final MBassador<BaseEvent> mEventBus = new MBassador<>();

    public void publishEvent(BaseEvent event) {
        mEventBus.publish(event);
    }

But then javadoc of publish(Object) states:

Synchronously publish a message to all registered listeners (this includes listeners defined for super types) The call blocks until every messageHandler has processed the message.

The part about "blocks until every messageHandler has processed the message" is unacceptable for me, so I thought that this is not the right solution.

However, having spent some time in the source code, it looks like the call to publish(Object) will block only until the processing have been delegated to messageHandlers, not until processing is actually done.

This looks like an incorrectly (or ambiguously) documented feature, but, before I build my system around it, I'd like to make sure that I got it right and the above code will indeed perform dispatching on the calling thread, and the calling thread will not wait for all processing to complete.

@bennidi
Copy link
Owner

bennidi commented Jun 22, 2017

The JavaDoc is clearly misleading here. Your statement is correct

call to publish(Object) will block only until the processing have been delegated to messageHandlers, not until processing is actually done.

I would greatly appreciate if you would take a bit of time to look through the docs and update them accordingly. It seems you have dug into the source code already and I believe that the docs can benefit from a "users" view. I will review a PR quickly then. Thanks.

@techyourchance
Copy link
Author

Just noticed I forgot to reply on this one.
I'm currently not confident that I have enough experience and understand all the intricate details in order to contribute, but, since I decided to use mbassador in my system, I will get to that point and gladly submit a PR.
Therefore, you can keep this issue open as a reminder for me.

@techyourchance
Copy link
Author

And you can even assign it to me.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants