Skip to content

Replace CountDownLatch with Deferred in BatchSpanProcessor - #119

Open
MattNot wants to merge 4 commits into
typelevel:mainfrom
MattNot:fixBatchSpanProcessorLatch
Open

Replace CountDownLatch with Deferred in BatchSpanProcessor#119
MattNot wants to merge 4 commits into
typelevel:mainfrom
MattNot:fixBatchSpanProcessorLatch

Conversation

@MattNot

@MattNot MattNot commented Jun 30, 2026

Copy link
Copy Markdown

Handles #118

@iRevive

iRevive commented Jul 27, 2026

Copy link
Copy Markdown
Contributor

Hey, thanks for the contribution!

Looks good to me. Once tests are green, we can merge and release.

@MattNot

MattNot commented Jul 28, 2026

Copy link
Copy Markdown
Author

Added a commit to optimize also the pollWaitTime <= Duration.Zero && currentBatchSize == 0 scenario

Comment on lines +123 to +124
currentSignal <- signalRef.getAndSet(newSignal)
_ <- currentSignal.get.timeoutTo(pollWaitTime, unit)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Here, we first get an existing deferred (let's call it old), then set a new one.
And in line 124 we wait for the completion of the old one, while the notifyWorker completes the new one.

So, the old will never be completed, and we always go through the timeout scenario.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Perhaps we can drop intermediate synchronization/notification and wait directly on queue.take. I will explore this idea.

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