# MyEventBus **Repository Path**: mapleSeriesX/MyEventBus ## Basic Information - **Project Name**: MyEventBus - **Description**: 事件发布-订阅总线 - **Primary Language**: Android - **License**: Apache-2.0 - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 0 - **Created**: 2020-07-13 - **Last Updated**: 2020-12-19 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README # MyEventBus #### Introduction EventBus is a publish/subscribe event bus framework used in Android development. Based on the observer model, the event receiver and sender are separated, avoiding complex and error-prone dependencies and life cycle issues, and simplifying components Communication, simple to use, high efficiency, small size! #### Software Architecture ![EventBus 原理图](eventbus.png) ##### Workflow: 1. Singleton mode: DCL + volatile, which greatly reduces the performance overhead caused by synchronized while preventing reordering and ensuring visibility between threads. 2. When the user registers, pass the class that uses EventBus, and save the class and all non-system methods under this class that contain custom annotation functions in the cache map collection. 3. When the user uses event delivery, iterate through the cache map collection, determine the type of delivery, determine whether a thread switch is required after the hit, and then reflect the call to the annotated function. 4. When the user cancels the registration, pass the class using EventBus and remove the item in the cache map collection.