diff options
author | Paul Phillips <paulp@improving.org> | 2013-03-06 08:05:12 -0800 |
---|---|---|
committer | Adriaan Moors <adriaan.moors@typesafe.com> | 2013-03-09 11:59:11 -0800 |
commit | e83defaa29bf8d7ed742a611c301ee8b04e971b8 (patch) | |
tree | 3dbacf0cde8a4a8801b3a40a685ffd8ac6c624b0 /src/interactive/scala/tools/nsc/interactive/PresentationCompilerThread.scala | |
parent | c6ca941ccc017a8869f4def717cfeb640f965077 (diff) | |
download | scala-e83defaa29bf8d7ed742a611c301ee8b04e971b8.tar.gz scala-e83defaa29bf8d7ed742a611c301ee8b04e971b8.tar.bz2 scala-e83defaa29bf8d7ed742a611c301ee8b04e971b8.zip |
Moved interactive sources into separate directory.
As with the preceding commit, this has build-internal
effects only.
Diffstat (limited to 'src/interactive/scala/tools/nsc/interactive/PresentationCompilerThread.scala')
-rw-r--r-- | src/interactive/scala/tools/nsc/interactive/PresentationCompilerThread.scala | 51 |
1 files changed, 51 insertions, 0 deletions
diff --git a/src/interactive/scala/tools/nsc/interactive/PresentationCompilerThread.scala b/src/interactive/scala/tools/nsc/interactive/PresentationCompilerThread.scala new file mode 100644 index 0000000000..a2d8e5d49a --- /dev/null +++ b/src/interactive/scala/tools/nsc/interactive/PresentationCompilerThread.scala @@ -0,0 +1,51 @@ +/* NSC -- new Scala compiler + * Copyright 2009-2013 Typesafe/Scala Solutions and LAMP/EPFL + * @author Martin Odersky + * @author Iulian Dragos + */ +package scala.tools.nsc.interactive + +/** A presentation compiler thread. This is a lightweight class, delegating most + * of its functionality to the compiler instance. + * + */ +final class PresentationCompilerThread(var compiler: Global, name: String = "") + extends Thread("Scala Presentation Compiler [" + name + "]") { + + /** The presentation compiler loop. + */ + override def run() { + compiler.debugLog("starting new runner thread") + while (compiler ne null) try { + compiler.checkNoResponsesOutstanding() + compiler.log.logreplay("wait for more work", { compiler.scheduler.waitForMoreWork(); true }) + compiler.pollForWork(compiler.NoPosition) + while (compiler.isOutOfDate) { + try { + compiler.backgroundCompile() + } catch { + case ex: FreshRunReq => + compiler.debugLog("fresh run req caught, starting new pass") + } + compiler.log.flush() + } + } catch { + case ex @ ShutdownReq => + compiler.debugLog("exiting presentation compiler") + compiler.log.close() + + // make sure we don't keep around stale instances + compiler = null + case ex: Throwable => + compiler.log.flush() + + ex match { + case ex: FreshRunReq => + compiler.debugLog("fresh run req caught outside presentation compiler loop; ignored") // This shouldn't be reported + case _ : Global#ValidateException => // This will have been reported elsewhere + compiler.debugLog("validate exception caught outside presentation compiler loop; ignored") + case _ => ex.printStackTrace(); compiler.informIDE("Fatal Error: "+ex) + } + } + } +} |