Skip to content

Broadcast events asynchronously

akwizgran requested to merge async-events into master

This branch makes the EventBus asynchronous. Instead of being broadcast and received on the same thread, events are received on a specific event thread, regardless of the thread on which they were broadcast. Events are still received in the same order as they were broadcast.

Platforms can use any suitable thread as the event thread. On Android, the UI thread is used as the event thread. This makes it easier to handle events in the UI. UI event handlers will be refactored in a later MR.

The main purpose of this change is to guarantee that events attached to DB transactions are received in the same order as the transactions were committed. This is made possible by broadcasting the events attached to a transaction before releasing the DB lock, which is now safe because the event bus is asynchronous. Together with the ability to attach actions to transactions, which is coming in a later MR, this will allow us to eliminate a lot of the complex code we currently use for avoiding UI/DB race conditions.

Merge request reports