diff options
author | Christopher Vogt <oss.nsp@cvogt.org> | 2016-03-13 03:18:18 -0400 |
---|---|---|
committer | Christopher Vogt <oss.nsp@cvogt.org> | 2016-03-19 21:13:48 -0400 |
commit | c095f435b68272d4ae0409ab4c9466145609710e (patch) | |
tree | 189f0f2755d8fd2e6af3eec9d514c29b3cebdef5 /stage2 | |
parent | ca7e166e09776410ef39e2808aab6a3fdd1e7911 (diff) | |
download | cbt-c095f435b68272d4ae0409ab4c9466145609710e.tar.gz cbt-c095f435b68272d4ae0409ab4c9466145609710e.tar.bz2 cbt-c095f435b68272d4ae0409ab4c9466145609710e.zip |
Refactored ClassLoaderCache to use key locked cache to pave the way for caching classloaders hierarchically without deadlocks
Diffstat (limited to 'stage2')
-rw-r--r-- | stage2/AdminTasks.scala | 4 | ||||
-rw-r--r-- | stage2/BasicBuild.scala | 5 | ||||
-rw-r--r-- | stage2/GitDependency.scala | 4 | ||||
-rw-r--r-- | stage2/Lib.scala | 9 | ||||
-rw-r--r-- | stage2/PackageBuild.scala | 2 | ||||
-rw-r--r-- | stage2/Stage2.scala | 2 | ||||
-rw-r--r-- | stage2/mixins.scala | 2 |
7 files changed, 15 insertions, 13 deletions
diff --git a/stage2/AdminTasks.scala b/stage2/AdminTasks.scala index e7fc78b..da4df9f 100644 --- a/stage2/AdminTasks.scala +++ b/stage2/AdminTasks.scala @@ -21,14 +21,14 @@ class AdminTasks(lib: Lib, args: Array[String], cwd: File){ ) // FIXME: this does not work quite yet, throws NoSuchFileException: /ammonite/repl/frontend/ReplBridge$.class lib.runMain( - "ammonite.repl.Main", Seq(), d.classLoader + "ammonite.repl.Main", Seq(), d.classLoader(new ClassLoaderCache(logger)) ) } def scala = { val version = args.lift(1).getOrElse(constants.scalaVersion) val scalac = new ScalaCompilerDependency( version ) lib.runMain( - "scala.tools.nsc.MainGenericRunner", Seq("-cp", scalac.classpath.string), scalac.classLoader + "scala.tools.nsc.MainGenericRunner", Seq("-cp", scalac.classpath.string), scalac.classLoader(new ClassLoaderCache(logger)) ) } def scaffoldBasicBuild: Unit = lib.scaffoldBasicBuild( cwd ) diff --git a/stage2/BasicBuild.scala b/stage2/BasicBuild.scala index 2f90197..a906b06 100644 --- a/stage2/BasicBuild.scala +++ b/stage2/BasicBuild.scala @@ -19,6 +19,7 @@ class BasicBuild( context: Context ) extends Build( context ) class Build(val context: Context) extends Dependency with TriggerLoop{ // library available to builds implicit final val logger: Logger = context.logger + implicit final val classLoaderCache: ClassLoaderCache = context.classLoaderCache override final protected val lib: Lib = new Lib(logger) // ========== general stuff ========== @@ -147,12 +148,12 @@ class Build(val context: Context) extends Dependency with TriggerLoop{ lib.compile( updated, sourceFiles, compileTarget, dependencyClasspath, scalacOptions, - zincVersion = zincVersion, scalaVersion = scalaVersion + zincVersion = zincVersion, scalaVersion = scalaVersion, context.classLoaderCache ) } def runClass: String = "Main" - def run: ExitCode = lib.runMainIfFound( runClass, context.args, classLoader ) + def run: ExitCode = lib.runMainIfFound( runClass, context.args, classLoader(context.classLoaderCache) ) def test: ExitCode = lib.test(context) diff --git a/stage2/GitDependency.scala b/stage2/GitDependency.scala index c3e38b6..993825e 100644 --- a/stage2/GitDependency.scala +++ b/stage2/GitDependency.scala @@ -7,7 +7,7 @@ import org.eclipse.jgit.lib.Ref case class GitDependency( url: String, ref: String // example: git://github.com/cvogt/cbt.git#<some-hash> -)(implicit val logger: Logger) extends Dependency{ +)(implicit val logger: Logger, classLoaderCache: ClassLoaderCache ) extends Dependency{ override def lib = new Lib(logger) // TODO: add support for authentication via ssh and/or https @@ -37,7 +37,7 @@ case class GitDependency( } val managedBuild = lib.loadDynamic( - Context( cwd = checkoutDirectory, args = Seq(), logger ) + Context( cwd = checkoutDirectory, args = Seq(), logger, classLoaderCache ) ) Seq( managedBuild ) } diff --git a/stage2/Lib.scala b/stage2/Lib.scala index e3e1ee1..218208d 100644 --- a/stage2/Lib.scala +++ b/stage2/Lib.scala @@ -58,11 +58,11 @@ final class Lib(logger: Logger) extends Stage1Lib(logger) with Scaffold{ def compile( updated: Boolean, sourceFiles: Seq[File], compileTarget: File, dependenyClasspath: ClassPath, - compileArgs: Seq[String], zincVersion: String, scalaVersion: String + compileArgs: Seq[String], zincVersion: String, scalaVersion: String, classLoaderCache: ClassLoaderCache ): File = { if(sourceFiles.nonEmpty) lib.zinc( - updated, sourceFiles, compileTarget, dependenyClasspath, compileArgs + updated, sourceFiles, compileTarget, dependenyClasspath, classLoaderCache, compileArgs )( zincVersion = zincVersion, scalaVersion = scalaVersion ) compileTarget } @@ -87,7 +87,8 @@ final class Lib(logger: Logger) extends Stage1Lib(logger) with Scaffold{ jarTarget: File, artifactId: String, version: String, - compileArgs: Seq[String] + compileArgs: Seq[String], + classLoaderCache: ClassLoaderCache ): File = { mkdir(Path(apiTarget)) if(sourceFiles.nonEmpty){ @@ -101,7 +102,7 @@ final class Lib(logger: Logger) extends Stage1Lib(logger) with Scaffold{ runMain( "scala.tools.nsc.ScalaDoc", args, - ScalaDependencies(scalaVersion)(logger).classLoader + ScalaDependencies(scalaVersion)(logger).classLoader(classLoaderCache) ) } } diff --git a/stage2/PackageBuild.scala b/stage2/PackageBuild.scala index 2866b7c..8f6d185 100644 --- a/stage2/PackageBuild.scala +++ b/stage2/PackageBuild.scala @@ -18,7 +18,7 @@ abstract class PackageBuild(context: Context) extends BasicBuild(context) with A private object cacheDocBasicBuild extends Cache[File] def docJar: File = cacheDocBasicBuild{ - lib.docJar( scalaVersion, sourceFiles, dependencyClasspath, apiTarget, jarTarget, artifactId, version, scalacOptions ) + lib.docJar( scalaVersion, sourceFiles, dependencyClasspath, apiTarget, jarTarget, artifactId, version, scalacOptions, context.classLoaderCache ) } override def jars = jar +: dependencyJars diff --git a/stage2/Stage2.scala b/stage2/Stage2.scala index 4145e55..a0a2b57 100644 --- a/stage2/Stage2.scala +++ b/stage2/Stage2.scala @@ -27,7 +27,7 @@ object Stage2{ } val task = argsV.lift( taskIndex ) - val context = Context( new File(argsV(0)), argsV.drop( taskIndex + 1 ), logger ) + val context = Context( new File(argsV(0)), argsV.drop( taskIndex + 1 ), logger, new ClassLoaderCache(logger) ) val first = lib.loadRoot( context ) val build = first.finalBuild diff --git a/stage2/mixins.scala b/stage2/mixins.scala index 2b38cdf..753ee60 100644 --- a/stage2/mixins.scala +++ b/stage2/mixins.scala @@ -29,7 +29,7 @@ trait ScalaTest extends Build with Test{ lib.runMain( "org.scalatest.tools.Runner", Seq("-R", discoveryPath, "-oF") ++ context.args.drop(1), - classLoader + classLoader(context.classLoaderCache) ) } } |