Skip to content

refactor: inline onEvent into MergeHub.tryProcessNext#2901

Merged
He-Pin merged 1 commit intoapache:mainfrom
He-Pin:refactor-mergehub-inline-onevent
May 9, 2026
Merged

refactor: inline onEvent into MergeHub.tryProcessNext#2901
He-Pin merged 1 commit intoapache:mainfrom
He-Pin:refactor-mergehub-inline-onevent

Conversation

@He-Pin
Copy link
Copy Markdown
Member

@He-Pin He-Pin commented Apr 24, 2026

Summary

  • Inline the Boolean-returning onEvent helper directly into MergedSourceLogic.tryProcessNext
  • Pattern-match the event in place: Element pushes and exits, Register/Deregister continue the @tailrec loop to drain control messages from the queue
  • Same wakeup protocol, same demand handling — purely a clarity refactor

Motivation

onEvent returned a Boolean flag whose only purpose was to tell tryProcessNext whether to continue looping. Folding the dispatch into the call site removes the indirection and makes the loop / exit conditions read in one place.

Test plan

  • sbt scalafmtAll
  • sbt stream/compile@tailrec accepted, no warnings
  • sbt "stream-tests/testOnly org.apache.pekko.stream.scaladsl.HubSpec" — 48/48 in 18s

Drop the Boolean-returning onEvent helper; pattern-match the event
directly inside tryProcessNext. Element pushes and exits, Register and
Deregister recurse via @tailrec to drain control messages from the
queue. Same protocol, no behavior change.
@He-Pin He-Pin requested a review from pjfanning April 24, 2026 11:50
Copy link
Copy Markdown
Member

@pjfanning pjfanning left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm

@He-Pin He-Pin merged commit b13d68f into apache:main May 9, 2026
20 of 24 checks passed
@He-Pin He-Pin deleted the refactor-mergehub-inline-onevent branch May 9, 2026 19:51
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