Skip to content

Fixed EventQueue and HeterEventQueue losing the queued events when a listener throws - #85

Open
Haititi wants to merge 1 commit into
wqking:masterfrom
Haititi:fix/queue-requeue-on-exception
Open

Haititi wants to merge 1 commit into
wqking:masterfrom
Haititi:fix/queue-requeue-on-exception

Conversation

@Haititi

@Haititi Haititi commented Oct 6, 2026

Copy link
Copy Markdown

process, processOne, processIf and processUntil swap the queue into a temporary list and dispatch from it. When a listener threw, the temporary list was destroyed by the unwinding and all the events that were not processed yet were lost.

Now the event being dispatched is removed (its listeners were invoked, maybe partially, and dispatching it again would invoke them again), the remaining events are put back to the front of the queue in their original order, the processed buffers are recycled, waiting threads are notified, and the exception propagates to the caller. If the predictor of processIf/processUntil throws, no event is removed.

Added unit tests and updated documents.

…listener throws

process, processOne, processIf and processUntil swap the queue into a temporary list and
dispatch from it. When a listener threw, the temporary list was destroyed by the unwinding
and all the events that were not processed yet were lost.

Now the event being dispatched is removed (its listeners were invoked, maybe partially, and
dispatching it again would invoke them again), the remaining events are put back to the
front of the queue in their original order, the processed buffers are recycled, waiting
threads are notified, and the exception propagates to the caller. If the predictor of
processIf/processUntil throws, no event is removed.

Added unit tests and updated documents.
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.

1 participant