--- a/src/Pure/Concurrent/future.scala Wed Jan 14 14:28:52 2015 +0100
+++ b/src/Pure/Concurrent/future.scala Wed Jan 14 16:23:33 2015 +0100
@@ -47,6 +47,7 @@
trait Promise[A] extends Future[A]
{
+ def cancel: Unit
def fulfill_result(res: Exn.Result[A]): Unit
def fulfill(x: A): Unit
}
@@ -78,6 +79,10 @@
{
override def is_finished: Boolean = promise.isCompleted
+ def cancel: Unit =
+ try { fulfill_result(Exn.Exn(Exn.Interrupt())) }
+ catch { case _: IllegalStateException => }
+
def fulfill_result(res: Exn.Result[A]): Unit =
res match {
case Exn.Res(x) => promise.success(x)