ZeroMemes/Alpine

Race condition between post and unsubscribe

ZeroMemes opened this issue · 0 comments

In multi-threaded applications, it's currently possible for calls to unsubscribe to complete while event dispatch is ongoing. This could end up being problematic, such an example could be a cleanup routine that runs immediately after unsubscribe and invalidates objects referenced by an event callback. In these situations, a synchronous ListenerList implementation would be necessary, implemented using either a mutex or read-write lock depending on the setup.

Currently, all ListenerList usages are backed by CopyOnWriteListenerList, which is hard-coded into EventManager.

Extensibility

  • Configurable ListenerList implementation via EventBusBuilder

ListenerList

  • Single-threaded implementation
  • Mutex wrapper
  • Read-write lock wrapper