summaryrefslogtreecommitdiff
path: root/src/compiler
diff options
context:
space:
mode:
authorMartin Odersky <odersky@gmail.com>2010-07-19 15:19:45 +0000
committerMartin Odersky <odersky@gmail.com>2010-07-19 15:19:45 +0000
commit30896b2f45f6e700e8ef332c3fe3ec62253cc731 (patch)
tree5f0dc2090cfee76122ba157ed5a5eb9fb988560a /src/compiler
parent7ca4628b2abe9c8bb876220a9990fab157b374a0 (diff)
downloadscala-30896b2f45f6e700e8ef332c3fe3ec62253cc731.tar.gz
scala-30896b2f45f6e700e8ef332c3fe3ec62253cc731.tar.bz2
scala-30896b2f45f6e700e8ef332c3fe3ec62253cc731.zip
added missing file.
Diffstat (limited to 'src/compiler')
-rw-r--r--src/compiler/scala/tools/nsc/util/InterruptReq.scala28
1 files changed, 28 insertions, 0 deletions
diff --git a/src/compiler/scala/tools/nsc/util/InterruptReq.scala b/src/compiler/scala/tools/nsc/util/InterruptReq.scala
new file mode 100644
index 0000000000..aa7804acbe
--- /dev/null
+++ b/src/compiler/scala/tools/nsc/util/InterruptReq.scala
@@ -0,0 +1,28 @@
+package scala.tools.nsc
+package util
+
+/** A class of work items to be used in interrupt requests.
+ */
+abstract class InterruptReq {
+ /** The result type of the operation
+ */
+ type R
+
+ /** The operation to be performed */
+ protected val todo: () => R
+
+ /** The result provided */
+ private var result: Option[R] = None
+
+ /** To be called from interrupted server to execute demanded task */
+ def execute(): Unit = synchronized {
+ result = Some(todo())
+ notify()
+ }
+
+ /** To be called from interrupting client to get result fo interrupt */
+ def getResult(): R = synchronized {
+ while (result.isEmpty) wait()
+ result.get
+ }
+}