Skip to content

Commit

Permalink
fix flush
Browse files Browse the repository at this point in the history
  • Loading branch information
schlawg committed Sep 24, 2024
1 parent 509a207 commit b1918f2
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions src/main/scala/netty/WorkerLoop.scala
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,15 @@ final class WorkerLoop(config: Config)(using Executor):
group.shutdownGracefully()

private def flush(): Unit =
val channelsToFlush = step.atLeast((flushQ.size * maxDelayFactor).toInt)
val iterator = flushQ.iterator()
for count <- 0 until channelsToFlush if iterator.hasNext do
iterator.next().flush()
iterator.remove()
var channelsToFlush = step.atLeast((flushQ.size * maxDelayFactor).toInt)

while channelsToFlush > 0 do
Option(flushQ.poll()) match
case Some(channel) =>
channel.eventLoop().execute(() => channel.flush())
channelsToFlush -= 1
case _ =>
channelsToFlush = 0

private def makeGroup(n: Int): EventLoopGroup =
if isMacOS then new KQueueEventLoopGroup(n)
Expand Down

0 comments on commit b1918f2

Please sign in to comment.