EventBus
EventBus copied to clipboard
Improve with read/write mutexes
AsyncEventBus uses normal std::mutex, maybe (probably) better approach would be to use read/write mutex e.g. std::shared_mutex
We can consider adding listener as write (we can benefit of changing capacity to even improve that), and making notification as read. This ticket needs some investigation is it possible and what need to be done to achieve better concurrency.
It would be nice to have:
- Some performance test to compare new/old approach. Please attach results old/new to PR.
- Unit test (if possible) of some multithreaded environment to test it.
May think about: (If you have any further suggestions please comment)
- How to achieve single "class" to not have separate AsyncEventBus and EventBus
- Maybe use some kind of CRTP to achieve thread safety ?