--- a/src/Pure/General/swing_thread.scala Mon Dec 07 23:06:03 2009 +0100
+++ b/src/Pure/General/swing_thread.scala Tue Dec 08 12:41:47 2009 +0100
@@ -10,6 +10,8 @@
import javax.swing.{SwingUtilities, Timer}
import java.awt.event.{ActionListener, ActionEvent}
+import scala.actors.{Future, Futures}
+
object Swing_Thread
{
@@ -21,13 +23,17 @@
/* main dispatch queue */
- def now[A](body: => A): A = {
+ def now[A](body: => A): A =
+ {
var result: Option[A] = None
if (SwingUtilities.isEventDispatchThread()) { result = Some(body) }
else SwingUtilities.invokeAndWait(new Runnable { def run = { result = Some(body) } })
result.get
}
+ def future[A](body: => A): Future[A] =
+ Futures.future(now(body))
+
def later(body: => Unit) {
if (SwingUtilities.isEventDispatchThread()) body
else SwingUtilities.invokeLater(new Runnable { def run = body })