Skip to content

Commit

Permalink
Remove ExecutionContext passing
Browse files Browse the repository at this point in the history
  • Loading branch information
Friendseeker committed Oct 12, 2024
1 parent 3bd4fbb commit 90bbcba
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 30 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -12,29 +12,25 @@ package sbt.internal.inc.consistent
* additional information regarding copyright ownership.
*/

import java.io.{ File, FileInputStream, FileOutputStream }
import java.util.Optional
import sbt.io.{ IO, Using }
import xsbti.compile.analysis.ReadWriteMappers
import xsbti.compile.{ AnalysisContents, AnalysisStore => XAnalysisStore }

import java.io.{ File, FileInputStream, FileOutputStream }
import java.util.Optional
import scala.util.control.Exception.allCatch
import xsbti.compile.analysis.ReadWriteMappers

import scala.concurrent.ExecutionContext

object ConsistentFileAnalysisStore {
def text(
file: File,
mappers: ReadWriteMappers,
sort: Boolean = true,
ec: ExecutionContext = ExecutionContext.global,
parallelism: Int = Runtime.getRuntime.availableProcessors()
): XAnalysisStore =
new AStore(
file,
new ConsistentAnalysisFormat(mappers, sort),
SerializerFactory.text,
ec,
parallelism
)

Expand All @@ -59,22 +55,19 @@ object ConsistentFileAnalysisStore {
file: File,
mappers: ReadWriteMappers,
sort: Boolean,
ec: ExecutionContext = ExecutionContext.global,
parallelism: Int = Runtime.getRuntime.availableProcessors()
): XAnalysisStore =
new AStore(
file,
new ConsistentAnalysisFormat(mappers, sort),
SerializerFactory.binary,
ec,
parallelism
)

private final class AStore[S <: Serializer, D <: Deserializer](
file: File,
format: ConsistentAnalysisFormat,
sf: SerializerFactory[S, D],
ec: ExecutionContext = ExecutionContext.global,
parallelism: Int = Runtime.getRuntime.availableProcessors()
) extends XAnalysisStore {

Expand All @@ -85,7 +78,7 @@ object ConsistentFileAnalysisStore {
if (!file.getParentFile.exists()) file.getParentFile.mkdirs()
val fout = new FileOutputStream(tmpAnalysisFile)
try {
val gout = new ParallelGzipOutputStream(fout, ec, parallelism)
val gout = new ParallelGzipOutputStream(fout, parallelism)
val ser = sf.serializerFor(gout)
format.write(ser, analysis, setup)
gout.close()
Expand Down
Original file line number Diff line number Diff line change
@@ -1,22 +1,14 @@
package sbt.inc.consistent

import java.io.{
BufferedInputStream,
BufferedReader,
ByteArrayInputStream,
ByteArrayOutputStream,
StringReader,
StringWriter
}
import java.util.zip.GZIPInputStream
import java.util.Arrays
import scala.util.Random
import org.scalatest.funsuite.AnyFunSuite
import sbt.internal.inc.consistent._
import sbt.internal.inc.consistent.*
import sbt.internal.inc.consistent.Compat.*
import sbt.io.IO
import Compat._

import scala.concurrent.ExecutionContext
import java.io.*
import java.util.Arrays
import java.util.zip.GZIPInputStream
import scala.util.Random

class ConsistentAnalysisFormatSuite extends AnyFunSuite {

Expand Down Expand Up @@ -100,7 +92,7 @@ class ConsistentAnalysisFormatSuite extends AnyFunSuite {
val a = new Array[Byte](size)
rnd.nextBytes(a)
val bout = new ByteArrayOutputStream()
val gout = new ParallelGzipOutputStream(bout, ExecutionContext.global, parallelism = threads)
val gout = new ParallelGzipOutputStream(bout, parallelism = threads)
gout.write(a)
gout.close()
val gin =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -507,7 +507,6 @@ object MixedAnalyzingCompiler {
useConsistent = false,
mappers = ReadWriteMappers.getEmptyMappers(),
sort = true,
ec = ExecutionContext.global,
parallelism = Runtime.getRuntime.availableProcessors(),
)

Expand All @@ -517,7 +516,6 @@ object MixedAnalyzingCompiler {
useConsistent: Boolean,
mappers: ReadWriteMappers,
sort: Boolean,
ec: ExecutionContext,
parallelism: Int,
): AnalysisStore = {
val fileStore = (useTextAnalysis, useConsistent) match {
Expand All @@ -528,7 +526,6 @@ object MixedAnalyzingCompiler {
file = analysisFile.toFile,
mappers = mappers,
sort = sort,
ec = ec,
parallelism = parallelism,
)
case (true, false) =>
Expand All @@ -538,7 +535,6 @@ object MixedAnalyzingCompiler {
file = analysisFile.toFile,
mappers = mappers,
sort = sort,
ec = ec,
parallelism = parallelism,
)
}
Expand Down

0 comments on commit 90bbcba

Please sign in to comment.