summaryrefslogtreecommitdiff
path: root/src/compiler/scala/tools/nsc/interactive/Global.scala
diff options
context:
space:
mode:
authorIulian Dragos <jaguarul@gmail.com>2011-08-31 10:09:26 +0000
committerIulian Dragos <jaguarul@gmail.com>2011-08-31 10:09:26 +0000
commitaade88f8a7b95980ba25d03322be275cc21856ae (patch)
tree1b12ac4622f53a9dda0c56960dd4539bf9fc8839 /src/compiler/scala/tools/nsc/interactive/Global.scala
parentd8add367dd9e432b53d98a33880bdf56a4505be1 (diff)
downloadscala-aade88f8a7b95980ba25d03322be275cc21856ae.tar.gz
scala-aade88f8a7b95980ba25d03322be275cc21856ae.tar.bz2
scala-aade88f8a7b95980ba25d03322be275cc21856ae.zip
Better handling of presentation compiler shutdown.
of deadlocks: when the PC was asked to shutdown, all work items in the work queue would be left pending, and no response would be set. This commit attempts to clean up a bit better: a shutdown request clears the work queue and all pending loaded&typed or parsed-entered requests by setting their responses to 'MissingResponse'. review by odersky.
Diffstat (limited to 'src/compiler/scala/tools/nsc/interactive/Global.scala')
-rw-r--r--src/compiler/scala/tools/nsc/interactive/Global.scala16
1 files changed, 16 insertions, 0 deletions
diff --git a/src/compiler/scala/tools/nsc/interactive/Global.scala b/src/compiler/scala/tools/nsc/interactive/Global.scala
index 3d7d14627c..362ec1bae0 100644
--- a/src/compiler/scala/tools/nsc/interactive/Global.scala
+++ b/src/compiler/scala/tools/nsc/interactive/Global.scala
@@ -320,6 +320,22 @@ class Global(settings: Settings, reporter: Reporter, projectName: String = "")
newTyperRun()
minRunId = currentRunId
demandNewCompilerRun()
+
+ case Some(ShutdownReq) =>
+ scheduler.synchronized { // lock the work queue so no more items are posted while we clean it up
+ val units = scheduler.dequeueAll {
+ case item: WorkItem => Some(item.raiseMissing())
+ case _ => Some(())
+ }
+ debugLog("ShutdownReq: cleaning work queue (%d items)".format(units.size))
+ debugLog("Cleanup up responses (%d loadedType pending, %d parsedEntered pending)"
+ .format(waitLoadedTypeResponses.size, getParsedEnteredResponses.size))
+ checkNoResponsesOutstanding()
+
+ log.flush();
+ throw ShutdownReq
+ }
+
case Some(ex: Throwable) => log.flush(); throw ex
case _ =>
}