diff options
author | Eugene Vigdorchik <eugenevigdorchik@epfl.ch> | 2010-09-15 09:10:31 +0000 |
---|---|---|
committer | Eugene Vigdorchik <eugenevigdorchik@epfl.ch> | 2010-09-15 09:10:31 +0000 |
commit | 6c4d41fbcc59ab2080036d7f0ed2f82d4911977d (patch) | |
tree | 6ce82cb52e0a58685a86aa2804c73b30c42ab4f9 /src | |
parent | 7bd08662d150bbb53d14866d19fcc3d923fff793 (diff) | |
download | scala-6c4d41fbcc59ab2080036d7f0ed2f82d4911977d.tar.gz scala-6c4d41fbcc59ab2080036d7f0ed2f82d4911977d.tar.bz2 scala-6c4d41fbcc59ab2080036d7f0ed2f82d4911977d.zip |
Shield interrupts against exceptions in user code
Diffstat (limited to 'src')
-rw-r--r-- | src/compiler/scala/tools/nsc/util/InterruptReq.scala | 13 |
1 files changed, 10 insertions, 3 deletions
diff --git a/src/compiler/scala/tools/nsc/util/InterruptReq.scala b/src/compiler/scala/tools/nsc/util/InterruptReq.scala index aa7804acbe..e7c05beb65 100644 --- a/src/compiler/scala/tools/nsc/util/InterruptReq.scala +++ b/src/compiler/scala/tools/nsc/util/InterruptReq.scala @@ -12,17 +12,24 @@ abstract class InterruptReq { protected val todo: () => R /** The result provided */ - private var result: Option[R] = None + private var result: Option[Either[R, Throwable]] = None /** To be called from interrupted server to execute demanded task */ def execute(): Unit = synchronized { - result = Some(todo()) + try { + result = Some(Left(todo())) + } catch { + case t => result = Some(Right(t)) + } notify() } /** To be called from interrupting client to get result fo interrupt */ def getResult(): R = synchronized { while (result.isEmpty) wait() - result.get + result.get match { + case Left(res) => res + case Right(t) => throw t + } } } |