Skip to content

Commit

Permalink
Fix: Runloop thread name is always zio-kafka-runloop-thread-0 (#909)
Browse files Browse the repository at this point in the history
  • Loading branch information
guizmaii authored Jun 8, 2023
1 parent bd59eca commit d38c190
Showing 1 changed file with 5 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,16 +9,18 @@ private[consumer] object RunloopExecutor {

private val counter: AtomicLong = new AtomicLong(0)

private def newSingleThreadedExecutor(i: Long): ZIO[Scope, Throwable, Executor] =
private val newSingleThreadedExecutor: ZIO[Scope, Throwable, Executor] =
ZIO.acquireRelease {
ZIO.attempt {
val javaExecutor =
Executors.newSingleThreadExecutor(runnable => new Thread(runnable, s"zio-kafka-runloop-thread-$i"))
Executors.newSingleThreadExecutor { runnable =>
new Thread(runnable, s"zio-kafka-runloop-thread-${counter.getAndIncrement()}")
}

Executor.fromJavaExecutor(javaExecutor) -> javaExecutor
}
} { case (_, executor) => ZIO.attempt(executor.shutdown()).orDie }.map(_._1)

val newInstance: ZIO[Scope, Throwable, Executor] = newSingleThreadedExecutor(counter.getAndIncrement())
val newInstance: ZIO[Scope, Throwable, Executor] = newSingleThreadedExecutor

}

0 comments on commit d38c190

Please sign in to comment.