feat: fs2 instead of parTraverse #46

Merged
gk1623 merged 4 commits from fs2 into master 2025-03-14 18:36:00 +00:00
4 changed files with 11 additions and 2 deletions

View File

@@ -13,6 +13,8 @@
//> using dep org.slf4j:slf4j-simple:2.0.17
//> using test.dep org.scalatest::scalatest::3.2.19
//> using dep org.typelevel::cats-effect-testing-scalatest::1.6.0
//> using dep "co.fs2::fs2-core:3.11.0"
//> using dep co.fs2::fs2-io:3.11.0
// sensible defaults for warnings and compiler checks
//> using options -deprecation -unchecked -feature

View File

@@ -15,6 +15,8 @@ import com.monovore.decline.effect._
import org.typelevel.log4cats.slf4j.Slf4jLogger
import org.typelevel.log4cats.Logger
import fs2.Stream
import assemblyIR as asm
import cats.data.ValidatedNel
import java.io.File
@@ -147,8 +149,13 @@ def compileCommandParallel(
log: Boolean,
outDir: Option[Path]
): IO[ExitCode] =
files
.parTraverse { file => compile(file.toAbsolutePath, outDir, log) }
Stream
.emits(files.toList)
.parEvalMapUnordered(Runtime.getRuntime.availableProcessors()) { file =>
compile(file.toAbsolutePath, outDir, log)
}
.compile
.toList
.map { exitCodes =>
exitCodes.filter(_ != 0) match {
case Nil => ExitCode.Success

BIN
wacc-compiler Executable file

Binary file not shown.

Binary file not shown.