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

Avoid blocked event bus #7

Merged
merged 9 commits into from
Nov 17, 2022
Merged

Avoid blocked event bus #7

merged 9 commits into from
Nov 17, 2022

Conversation

pfeuffer
Copy link
Member

@pfeuffer pfeuffer commented Nov 15, 2022

Proposed changes

The old synchronization of asynchronous non-concurrent event handlers could lead to a blocked event bus with a single long-running event handler. For this to happen, the following situation had to occur:

  1. A event had to be thrown and a (asynchronous non-concurrent) handler has to take some time to process this event
  2. During this processing more events have to be thrown that have to be handled by this blocked event handler.

In this case, the handling of the following events are blocked by the synchronization in the SynchronizedEventHandler class until the first event has been processed completely. Because the synchonization happens in the handleEvent method inside the handler, this blocks a thread of the executor per event, until all threads are blocked an therefore no more asynchronous events whatsoever can be processed any more.

To avoid such situations, the synchronization is now done outside of the executor and its threads. To do so, the new class ExecutorSerializer is introduced. This class can be seen as a steward, that blocks events for event handlers, whenever a event handler of the same type is already queued in the executor to process another event. The waiting event is put in a queue outside the executor an will be taken into account again, whenever the first process has finished.

Your checklist for this pull request

Put an x in the boxes that apply. You can also fill these out after creating the PR. If you're unsure about any of them, don't hesitate to ask. We're here to help! This is simply a reminder of what we are going to look for before merging your code.

Contributor:

  • PR is well described and the description can be used as a commit message on squash
  • Related issues linked to PR if existing and labels set
  • New code is covered with unit tests

Reviewer:

  • The clean code principles are respected (CleanCode)
  • All new code/logic is implemented on the right spot / "Should this be done here?"
  • UI changes fits into the layout
  • The UI views / components are responsive (mobile views)
  • Correct translations are available

Checklist for branch merge request (not required for forks)

@pfeuffer pfeuffer marked this pull request as ready for review November 17, 2022 06:51
@Pilopa Pilopa merged commit e4d9374 into main Nov 17, 2022
@delete-merged-branch delete-merged-branch bot deleted the feature/avoid_blocked_event_bus branch November 17, 2022 19:01
pfeuffer added a commit that referenced this pull request Mar 18, 2024
The old synchronization of asynchronous non-concurrent event handlers could lead to a blocked event bus with a single long-running event handler. For this to happen, the following situation had to occur:

A event had to be thrown and a (asynchronous non-concurrent) handler has to take some time to process this event
During this processing more events have to be thrown that have to be handled by this blocked event handler.
In this case, the handling of the following events are blocked by the synchronization in the SynchronizedEventHandler class until the first event has been processed completely. Because the synchronization happens in the handleEvent method inside the handler, this blocks a thread of the executor per event, until all threads are blocked an therefore no more asynchronous events whatsoever can be processed any more.

To avoid such situations, the synchronization is now done outside of the executor and its threads. To do so, the new class ExecutorSerializer is introduced. This class can be seen as a steward, that blocks events for event handlers, whenever a event handler of the same type is already queued in the executor to process another event. The waiting event is put in a queue outside the executor an will be taken into account again, whenever the first process has finished.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants