Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Race condition between post and unsubscribe #14

Closed
4 tasks done
ZeroMemes opened this issue May 22, 2023 · 0 comments
Closed
4 tasks done

Race condition between post and unsubscribe #14

ZeroMemes opened this issue May 22, 2023 · 0 comments
Labels
Milestone

Comments

@ZeroMemes
Copy link
Owner

ZeroMemes commented May 22, 2023

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
@ZeroMemes ZeroMemes added the bug label May 22, 2023
@ZeroMemes ZeroMemes added this to the 3.0.0 milestone May 22, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant