asaskevich / EventBus

[Go] Lightweight eventbus with async compatibility for Go
MIT License
1.74k stars 220 forks source link

do not hold lock on whole publish #53

Open Snawoot opened 2 years ago

Snawoot commented 2 years ago

Fix #35 Fix #52

This PR does not holds lock during whole publish process. It saves from deadlocks when callbacks also trying to publish something or manage subscription on the bus.

Before this publish worked with copy of active handlers anyway, so now it's safe to work with bus because it uses locks only to manage internal state, not causing deadlock in subsequent calls from handlers.

There is a slight change in the handler object: once boolean flag replaced with pointer to sync.Once. This achieves following goals:

Tochemey commented 1 year ago

Hello @Snawoot and @millken it seems the PR is not merged. Any reason why?

Snawoot commented 1 year ago

@Tochemey Because only @asaskevich can merge.

Tochemey commented 1 year ago

Hello @asaskevich any reason this PR is not yet merged. Also do you advice to still use this library in production because I have not seen any update to it.?

@Tochemey Because only @asaskevich can merge.

Thank you so much @Snawoot