Skip to content

EventBus

Alex Robin edited this page Dec 21, 2016 · 3 revisions

The event bus is at the core of sensorhub implementation. It is the main way of exchanging asynchronous messages between components, and is based on the publish-subscribe paradigm. For instance, real-time data produced by sensor drivers is pushed to the bus, and any module can register to receive the corresponding "data" events.

![Direct Tasking Sequence Diagram](http://g.gravizo.com/g? @startuml; participant "Producer" as P; participant "EventBus" as B; participant "Listener1" as L1; participant "Listener2" as L2; P -> B: registerProducer; L1 -> B: registerListener; L2 -> B: registerListener; |||; P --> B: publishEvent; B --> L1: dispatch; B --> L2: dispatch; note right of L2: ; @enduml )

For efficiency, the implementation creates a dedicated instance of IEventHandler for each different listener/topic combination so we can avoid a map lookup for each message.

OSH now uses an asynchronous implementation of IEventHandler called AsyncEventHandler that multi-threads event dispatching while maintaining message order.

Clone this wiki locally