diff options
author | Iulian Dragos <jaguarul@gmail.com> | 2012-10-10 11:28:00 +0200 |
---|---|---|
committer | Iulian Dragos <jaguarul@gmail.com> | 2012-10-10 11:28:00 +0200 |
commit | 19ea47b3425f973c1ca92890cb8ee561b0ecab3d (patch) | |
tree | 76c0570c87706efabb659b2fb70f040c50135cc6 /test/files/presentation/forgotten-ask.scala | |
parent | 859ec02495993f225647df50397b042a3172351b (diff) | |
download | scala-19ea47b3425f973c1ca92890cb8ee561b0ecab3d.tar.gz scala-19ea47b3425f973c1ca92890cb8ee561b0ecab3d.tar.bz2 scala-19ea47b3425f973c1ca92890cb8ee561b0ecab3d.zip |
Fixed SI-6505. Respond to ask calls by immediate failure even after compiler shutdown.
When the compiler is asked to shutdown, it may still have items on the working queue, and more can be added by clients in other thread that don't *know* the compiler is down yet. These requests were never serviced, leading to deadlocks or timeouts.
review by @odersky, @hubertp
Diffstat (limited to 'test/files/presentation/forgotten-ask.scala')
-rw-r--r-- | test/files/presentation/forgotten-ask.scala | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/test/files/presentation/forgotten-ask.scala b/test/files/presentation/forgotten-ask.scala new file mode 100644 index 0000000000..358dd75e98 --- /dev/null +++ b/test/files/presentation/forgotten-ask.scala @@ -0,0 +1,33 @@ +import scala.tools.nsc.interactive._ +import tests._ + +/** Test that no ask calls are left unanswered after a compiler has shut down. */ +object Test extends InteractiveTest { + import compiler._ + + def askItem(): Response[Unit] = { + compiler.askForResponse { () => + Thread.sleep(100) + } + } + + final val Timeout = 5000 //ms + + override def main(args: Array[String]) { + val item1 = askItem() + + compiler.askShutdown() + + Thread.sleep(1000) // wait a bit, the compiler is shutting down + val item2 = askItem() + + item1.get(Timeout) match { + case None => println("TIMEOUT") + case _ => + } + item2.get(Timeout) match { + case None => println("TIMEOUT") + case _ => + } + } +}
\ No newline at end of file |