From 30896b2f45f6e700e8ef332c3fe3ec62253cc731 Mon Sep 17 00:00:00 2001 From: Martin Odersky Date: Mon, 19 Jul 2010 15:19:45 +0000 Subject: added missing file. --- .../scala/tools/nsc/util/InterruptReq.scala | 28 ++++++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100644 src/compiler/scala/tools/nsc/util/InterruptReq.scala 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 + } +} -- cgit v1.2.3